Answers.Body: <p>Your search syntax of <code>craft.entries.section('pages').search('foo:bar foo2:bar2')</code> should work and is the equivalent of saying "give me all of the entries in the <code>pages</code> section where the field <code>foo</code> is equal to <code>bar</code> <strong>and</strong> the field <code>foo2</code> is equal to <code>bar2</code>.</p>
  
  <p>Something that trips people up often is that Craft doesn't do fuzzy searching by default. So <code>foo:bar</code> will match <em>exactly</em> <code>bar</code>, but it will not match <code>bars</code>.  You'd need to use <code>foo:bar*</code> for that.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-12T05:52:37.137Z
Answers.Text: Oh, maybe I'm wrong somewhere else then. My search uses a lightswitch and a position:
  
  craft.entries.section('pages').search('onHomePage::true position::"left"')
  
  I get the pages who are not "onHomePage" as well
Answers.UserDisplayName: Julien
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-23T21:59:17.977Z
Answers.Text: And it appears for OR searches this works: search('foo:bar OR foo2:bar2')
Answers.UserDisplayName: JamesNZ
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-04T14:26:00.833Z
Answers.Text: Just to clarify, as foo and bar are petpeeves of mine that I find ... less than helpful; the syntax is .search('fieldHandle:textToFind otherFieldHandle:someOtherText')
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-12T05:27:24.477Z
Answers.LastActivityDate: 2015-06-12T05:27:24.477Z
Answers.UserDisplayName: Brad Bell
Body: <p>My question could seem obvious but I don't find the solution.</p>
  
  <p>How to make a search on two fields, like:</p>
  
  <pre><code>craft.entries.section('pages').search('foo:bar foo2:bar2')
  </code></pre>
  
  <p>I tried</p>
  
  <pre><code>search('foo:bar', 'foo2:bar4')
  search('foo:bar and foo2:bar2')
  </code></pre>
  
  <p>none of these seem to work</p>
  
Tags: <search>
Title: multiple search
ThreadText: # multiple search
  
  (Asked by: username_0 on 2015-06-12)
  
  My question could seem obvious but I don't find the solution.
  
  How to make a search on two fields, like:
  
  ```
  craft.entries.section('pages').search('foo:bar foo2:bar2')
  
  ```
  
  I tried
  
  ```
  search('foo:bar', 'foo2:bar4')
  search('foo:bar and foo2:bar2')
  
  ```
  
  none of these seem to work
  
  **Tags:** search
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-12. Score: 6
  
  Your search syntax of `craft.entries.section('pages').search('foo:bar foo2:bar2')` should work and is the equivalent of saying "give me all of the entries in the `pages` section where the field `foo` is equal to `bar` **and** the field `foo2` is equal to `bar2`.
  
  Something that trips people up often is that Craft doesn't do fuzzy searching by default. So `foo:bar` will match *exactly* `bar`, but it will not match `bars`. You'd need to use `foo:bar*` for that.
  
  > **Comments:**
  > **username_0**: Oh, maybe I'm wrong somewhere else then. My search uses a lightswitch and a position:  craft.entries.section('pages').search('onHomePage::true position::"left"')  I get the pages who are not "onHomePage" as well  
  > **username_2**: And it appears for OR searches this works: search('foo:bar OR foo2:bar2')  
  > **username_3**: Just to clarify, as foo and bar are petpeeves of mine that I find ... less than helpful; the syntax is .search('fieldHandle:textToFind otherFieldHandle:someOtherText')  
  
  ---
  
  