Jump to content

Help understanding search results


Tyssen
 Share

Recommended Posts

I've implemented a site search on a site and am a bit confused about how it processes results.

For instance, a search for art union produces no results, same for a search for art, but a search for union produces 5 results including the one I was hoping would come up which has a title of art union.

How/why is that happening and is there anything to configure to improve the results?

My search form looks like:

<form action="<?php echo $pages->get("template=search")->url; ?>" method="get">
<input type="text" name="q">
<button type="submit">Search</button>
</form>

and the search template:

if($q = $sanitizer->selectorValue($input->get->q)) :

  $input->whitelist('q', $q);

  $matches = $pages->find("title|body|summary~=$q,template!=admin, limit=50");

  $count = count($matches);

  if($count) :
    foreach($matches as $m) :
      …
    endforeach;
  endif;
else:
  …
endif;
Link to comment
Share on other sites

This is documented behavior. From PW's selector documentation:

The *= and ~= rely upon MySQL fulltext indexes, which only index words of at least a certain length (configurable, but typically 4 characters). They also don't index common English words called stopwords. So while it's preferable to use *= and ~= for their speed, if you aren't getting the results you need, you should consider using %= instead (if you can handle the speed hit).

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...