Answers.Body: <blockquote>
    <p>This section has about 30 fields I would like a user to be able to search for any text in any field, so I wont know the field names ahead of time. The user will not know the handles of the fields so that is not an option unfortunately.</p>
  </blockquote>
  
  <p>I don't think this is going to be possible natively.  Maybe if the 30 fields were all relational (entries, users, tags, categories, etc.), you could pull it off with some multi-step <a href="https://docs.craftcms.com/v3/relations.html" rel="nofollow noreferrer">relation</a> queries, but it wouldn't be pretty.</p>
  
  <p>Alternatively, you could write a <a href="https://pluginfactory.io" rel="nofollow noreferrer">custom plugin</a> that implemented its own custom search logic or there are some existing plugins that integrate with external search providers like <a href="https://github.com/joshuabaker/craft-algolia" rel="nofollow noreferrer">Algolia</a> that might do what you're looking for.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-02T18:20:22.717Z
Answers.Text: There seems to be very little documentation on how to do this kind of search in a custom plugin. Respectfully, I do appreciate that I could write a custom plugin, and that is already obvious, but without specifying at all how to write some custom search logic, or pointing to any docs or examples, I am not able to proceed. For this reason I am unvoting the above being an answer.
Answers.UserDisplayName: ironfish
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-11T18:09:22.680Z
Answers.LastActivityDate: 2018-06-11T18:09:22.680Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have implemented the standard search form at:
  <a href="https://docs.craftcms.com/v2/templating/search-form.html" rel="nofollow noreferrer">https://docs.craftcms.com/v2/templating/search-form.html</a></p>
  
  <p>and added fuzzy searching:</p>
  
  <pre><code>{% set entries = craft.entries({
  search: {
      query: query,
      subLeft: true,
      subRight: true
  }
  }) %}
  </code></pre>
  
  <p>as per:</p>
  
  <p><a href="https://docs.craftcms.com/v2/searching.html" rel="nofollow noreferrer">https://docs.craftcms.com/v2/searching.html</a></p>
  
  <p>And this works well for finding entries using a single search word, even if it is misspelled.</p>
  
  <p>However I need to be able to find entries that contain more than one search term, eg:</p>
  
  <p>Toronto AND French</p>
  
  <p>And for that I get "No results found" in search results.</p>
  
  <p>Searching for "Toronto French" will result in "Your search for “Toronto French” didn’t return any results." </p>
  
  <p>The page:</p>
  
  <p><a href="https://docs.craftcms.com/v2/searching.html" rel="nofollow noreferrer">https://docs.craftcms.com/v2/searching.html</a>
  Does describe an OR search:</p>
  
  <blockquote>
    <p>salty OR dog  containing either “salty” or “dog” (or both).</p>
  </blockquote>
  
  <p>But I do not seem to be able to find a way to AND...</p>
  
  <p>Is there a way to do this?</p>
  
  <p>Much thanks ahead of time......</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-09T17:31:13.070Z
Comments.Text: Isn't that enough `salty dog` -> 'containing both “salty” and “dog”.' you could maybe create your own function to parse an `and` between your words but it's probably easier to use the default way without the `and` -> separate your terms with a whitespace
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-09T17:40:28.093Z
Comments.Text: Hi Robin. I have an Entry that has the words "Toronto" and "French" in it. Searching for "Toronto OR French" will find the entry. Searching for "Toronto French" will result in "Your search for “Toronto French” didn’t return any results." So unfortunately separating search terms with a whitespace does not work :(
Comments.UserDisplayName: ironfish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-09T17:44:26.810Z
Comments.Text: I am searching a Section that has multiple fields in it. One field contains "Toronto", another field contains "French". Maybe if both words were in a single field then searching for "Toronto French" would work? Is there maybe a way to tell Craft to search all fields? Maybe I have neglected to do that?
Comments.UserDisplayName: ironfish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-10T12:35:55.823Z
Comments.Text: Searching using two words and a whitespace between them will work if the words are in the same field. But not if they are in different fields. If using OR then the search will work with words being in different fields. I have rebuilt the search index, done a lot of Googling to try and find a solution, but can't seem to find anything to resolve this. Any help much appreciated.
Comments.UserDisplayName: ironfish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-10T12:39:27.913Z
Comments.Text: It can be done with a normal query `craft.entries.fieldHandleOne('*term*').fieldHandleTwo('*term*').all()` if your fields are known /specified. Otherwise you'll need to prepend the field handle in your search. Or you need to create a custom search
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-10T12:44:50.013Z
Comments.Text: Thanks Robin. This section has about 30 fields I would like a user to be able to search for any text in any field, so I wont know the field names ahead of time. The user will not know the handles of the fields so that is not an option unfortunately.
Comments.UserDisplayName: ironfish
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-12T15:31:26.167Z
Comments.Text: Thanks Robin - I will look into how to develop a custom search.....
Comments.UserDisplayName: ironfish
Tags: <search>
Title: ANDing search terms
ThreadText: # ANDing search terms
  
  (Asked by: username_0 on 2018-06-09)
  
  I have implemented the standard search form at:
  <https://docs.craftcms.com/v2/templating/search-form.html>
  
  and added fuzzy searching:
  
  ```
  {% set entries = craft.entries({
  search: {
      query: query,
      subLeft: true,
      subRight: true
  }
  }) %}
  
  ```
  
  as per:
  
  <https://docs.craftcms.com/v2/searching.html>
  
  And this works well for finding entries using a single search word, even if it is misspelled.
  
  However I need to be able to find entries that contain more than one search term, eg:
  
  Toronto AND French
  
  And for that I get "No results found" in search results.
  
  Searching for "Toronto French" will result in "Your search for “Toronto French” didn’t return any results."
  
  The page:
  
  <https://docs.craftcms.com/v2/searching.html>
  Does describe an OR search:
  
  > salty OR dog containing either “salty” or “dog” (or both).
  
  But I do not seem to be able to find a way to AND...
  
  Is there a way to do this?
  
  Much thanks ahead of time......
  
  **Tags:** search
  
  > **Comments:**
  > **username_1**: Isn't that enough `salty dog` -> 'containing both “salty” and “dog”.' you could maybe create your own function to parse an `and` between your words but it's probably easier to use the default way without the `and` -> separate your terms with a whitespace  
  > **username_0**: Hi username_1. I have an Entry that has the words "Toronto" and "French" in it. Searching for "Toronto OR French" will find the entry. Searching for "Toronto French" will result in "Your search for “Toronto French” didn’t return any results." So unfortunately separating search terms with a whitespace does not work :(  
  > **username_0**: I am searching a Section that has multiple fields in it. One field contains "Toronto", another field contains "French". Maybe if both words were in a single field then searching for "Toronto French" would work? Is there maybe a way to tell Craft to search all fields? Maybe I have neglected to do that?  
  > **username_0**: Searching using two words and a whitespace between them will work if the words are in the same field. But not if they are in different fields. If using OR then the search will work with words being in different fields. I have rebuilt the search index, done a lot of Googling to try and find a solution, but can't seem to find anything to resolve this. Any help much appreciated.  
  > **username_1**: It can be done with a normal query `craft.entries.fieldHandleOne('*term*').fieldHandleTwo('*term*').all()` if your fields are known /specified. Otherwise you'll need to prepend the field handle in your search. Or you need to create a custom search  
  > **username_0**: Thanks username_1. This section has about 30 fields I would like a user to be able to search for any text in any field, so I wont know the field names ahead of time. The user will not know the handles of the fields so that is not an option unfortunately.  
  > **username_0**: Thanks username_1 - I will look into how to develop a custom search.....  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-06-11. Score: 2
  
  > This section has about 30 fields I would like a user to be able to search for any text in any field, so I wont know the field names ahead of time. The user will not know the handles of the fields so that is not an option unfortunately.
  
  I don't think this is going to be possible natively. Maybe if the 30 fields were all relational (entries, users, tags, categories, etc.), you could pull it off with some multi-step [relation](https://docs.craftcms.com/v3/relations.html) queries, but it wouldn't be pretty.
  
  Alternatively, you could write a [custom plugin](https://pluginfactory.io) that implemented its own custom search logic or there are some existing plugins that integrate with external search providers like [Algolia](https://github.com/joshuabaker/craft-algolia) that might do what you're looking for.
  
  > **Comments:**
  > **username_0**: There seems to be very little documentation on how to do this kind of search in a custom plugin. Respectfully, I do appreciate that I could write a custom plugin, and that is already obvious, but without specifying at all how to write some custom search logic, or pointing to any docs or examples, I am not able to proceed. For this reason I am unvoting the above being an answer.  
  
  ---
  
  