<p><code>foo bar</code> implies <code>foo AND bar</code> by default.  What you're probably looking for is <code>foo OR bar</code>.</p>

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

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

<p>You can see more search syntax options <a href="http://buildwithcraft.com/docs/searching" rel="nofollow">here</a>.</p>

CC BY-SA 3.0
2015-06-26T00:44:46.497Z
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.
Jack McKenzie
CC BY-SA 3.0
2015-06-26T01:05:01.580Z
Updated my answer.
Brad Bell
CC BY-SA 3.0
2015-06-26T02:45:31.717Z
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.
Jack McKenzie
CC BY-SA 3.0
2015-06-26T05:43:31.360Z
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
CC BY-SA 3.0
2015-06-26T00:40:25.623Z
2015-06-26T01:04:55.810Z
2015-06-26T01:04:55.810Z
Brad Bell
<p>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:</p>

<p>Description Field: foo</p>

<p>Body Field: bar baz</p>

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

<p>I have rebuilt the search index.</p>

CC BY-SA 3.0
2015-06-26T00:29:58.880Z
I'm using set entries = craft.entries.search(query).order('score') to conduct the search
Jack McKenzie
<search>
Site search that matches in more than one field
# Site search that matches in more than one field

(Asked by: username_0 on 2015-06-26)

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.

**Tags:** search
> **Comments:**
> **username_0**: I'm using set entries = craft.entries.search(query).order('score') to conduct the search  

---

## 1 answers

### Answer by username_1 on 2015-06-26. Score: 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](http://buildwithcraft.com/docs/searching).

> **Comments:**
> **username_0**: 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.  
> **username_1**: Updated my answer.  
> **username_0**: 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.  
> **username_1**: 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.  

---

