I'm wondering how to conduct a site search that takes search words and matches them in more than one field. So for example if I have an entry with fields that contain the following words:

Description Field: foo

Body Field: bar baz

A search for 'foo', or 'bar', or 'bar baz' finds the entry, but a search for 'foo bar' does not.

I have rebuilt the search index.

  • I'm using set entries = craft.entries.search(query).order('score') to conduct the search Commented Jun 26, 2015 at 0:29

1 Answer 1


foo bar implies foo AND bar by default. What you're probably looking for is foo OR bar.

If you look at craft_searchindex, you can see that keywords for fields are indexed on a per field basis, which is why you'd need the OR to search across multiple fields.

You can omit OR if you already know the field names ahead of time, though. field1:foo field2:bar.

You can see more search syntax options here.

  • No, I am looking for foo AND bar, just as I am looking for bar AND baz. The former are found across two fields whereas the latter is in one field. Commented Jun 26, 2015 at 0:44
  • Updated my answer.
    – Brad Bell
    Commented Jun 26, 2015 at 1:05
  • Thanks Brad. What I am really looking for is a site search solution that an end user can use to search the whole site (which usually involves many sections and fields). So what you are suggesting is that I have to take the search string and apply it across all sections and fields to effectively join them up. Commented Jun 26, 2015 at 2:45
  • You can have the search form submit to a custom plugin that does whatever processing/manipulation on the search string it needs to before passing it on to Craft.
    – Brad Bell
    Commented Jun 26, 2015 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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