5

Leading on from this question by Chris Lewis

I can't seem to find anything on the technicals, but by what criteria "best-match to worst-match" calculated? For example, if I was to have, an entry with the title "Top Trees" then "Top Trees" I would expect to be a "best-match"?

This is a little bit "How do I get my post to the first page of the Craft Search!" I know.

10

When Craft is determining a matching element’s score, it will loop through each of the search terms, and for each one, loop through each of the element’s attributes, and add the following points to the element’s score:

  • If the attribute is an exact match of the search term, 100 points will be added
  • If the attribute contains a full-word match of the search term, 50 points will be added
  • If the attribute contains a partial match of the search term, 10 points will be added

If the term is part of an “OR” group, then its points will be divided by the total number of terms within that group. So for example, if searching for “gin OR tonic” and an exact match is found within one of the custom fields, rather than getting 100 points, the element would only get 50.

As of today’s 2.2.2582 release, if the attribute is the Title field, then the score will be multiplied by 5. For example, an exact match in the Title field would actually be 500 points, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.