Answers.Body: <p>I found the problem, which is pretty ridiculous but something that probably happens to other developers who are using multiple languages.. (I hope).</p>
  
  <p>In</p>
  
  <pre><code>query: 'klantLocation:' ~ searchL,
  </code></pre>
  
  <p>I had to replace <code>klantLocation</code> with <code>klantLocatie</code></p>
  
  <p>Pretty dumb mistake but hopefully someone else will find some help in my mistake</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-18T20:00:11.410Z
Answers.LastActivityDate: 2017-01-18T20:00:11.410Z
Answers.UserDisplayName: Mosh
Body: <p>I have a search form that contains a dropdown based on categories and a text field to search by title. This works the way it should. Now I need to add an extra text field to search by location as well but when I do that the search form doesn't work anymore.</p>
  
  <p>What I have is:</p>
  
  <pre><code>{# defaults #}
      {% set queryParams = {
        section: 'klanten',
        order: 'title asc',
      } %}
  
  
      {# Build a category array beginning with 'and' and add targetElement objects with selected categories Ids to it #}
      {% set categoriesArray = ['and'] %}
  
      {% set searchCat = craft.request.getParam('cat') %}
      {% if searchCat is not empty %}
        {% set searchThemeCat = craft.categories.slug(searchCat).ids() %}
        {% set categoriesArray = categoriesArray|merge([{
          targetElement: searchThemeCat,
        }]) %}
      {% endif %}
  
  
      {% if categoriesArray|length &gt; 1 %}
  
        {% set queryParams = queryParams|merge({
          relatedTo: categoriesArray
        }) %}
  
      {% endif %}
  
      {# search #}
      {% set searchQ = craft.request.getParam('q') %}
      {% if searchQ is not empty %}
        {% set queryParams = queryParams|merge({
          search: {
            query: 'title:' ~ searchQ,
            subLeft: true,
            subRight: true,
          }
        }) %}
      {% endif %}
  
  {% set klantEntries = craft.entries(queryParams) %}
  </code></pre>
  
  <p>Now I thought adding the following would allow me to search by location as well but instead it says 'no results are found for ""' which means that it search query is empty, I guess?</p>
  
  <pre><code>{% set searchL = craft.request.getParam('loc') %}
      {% if searchL is not empty %}
        {% set queryParams = queryParams|merge({
          search: {
            query: 'klantLocation:' ~ searchL,
            subLeft: true,
            subRight: true,
          }
        }) %}
      {% endif %}
  </code></pre>
  
  <p>I don't really know how to fix it, I've been looking through a lot of examples but I can't get it to work, any help would be appreciated</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-16T23:55:45.960Z
Comments.Text: What type of field is klantLocation?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-17T11:18:10.503Z
Comments.Text: @BradBell it's a plain text field
Comments.UserDisplayName: Mosh
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-18T03:34:13.660Z
Comments.Text: You're sure `searchL` is what you're expecting it to be?  I'd also enable devMode, run the search, then find the SQL that's being generated in `craft/storage/runtime/logs` and make sure it looks correct for the data you're looking for.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-18T20:03:15.743Z
Comments.Text: @BradBell Thank you, telling me to check the logs made me realise my field wasn't called 'klantLocation' but 'klantLocatie'. Pretty dumb mistake, but thank you for your time and help
Comments.UserDisplayName: Mosh
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-18T21:17:39.850Z
Comments.Text: Glad you're all sorted!
Comments.UserDisplayName: Brad Bell
Tags: <search>
Title: Search not working with extra field
ThreadText: # Search not working with extra field
  
  (Asked by: username_0 on 2017-01-16)
  
  I have a search form that contains a dropdown based on categories and a text field to search by title. This works the way it should. Now I need to add an extra text field to search by location as well but when I do that the search form doesn't work anymore.
  
  What I have is:
  
  ```
  {# defaults #}
      {% set queryParams = {
        section: 'klanten',
        order: 'title asc',
      } %}
  
      {# Build a category array beginning with 'and' and add targetElement objects with selected categories Ids to it #}
      {% set categoriesArray = ['and'] %}
  
      {% set searchCat = craft.request.getParam('cat') %}
      {% if searchCat is not empty %}
        {% set searchThemeCat = craft.categories.slug(searchCat).ids() %}
        {% set categoriesArray = categoriesArray|merge([{
          targetElement: searchThemeCat,
        }]) %}
      {% endif %}
  
      {% if categoriesArray|length > 1 %}
  
        {% set queryParams = queryParams|merge({
          relatedTo: categoriesArray
        }) %}
  
      {% endif %}
  
      {# search #}
      {% set searchQ = craft.request.getParam('q') %}
      {% if searchQ is not empty %}
        {% set queryParams = queryParams|merge({
          search: {
            query: 'title:' ~ searchQ,
            subLeft: true,
            subRight: true,
          }
        }) %}
      {% endif %}
  
  {% set klantEntries = craft.entries(queryParams) %}
  
  ```
  
  Now I thought adding the following would allow me to search by location as well but instead it says 'no results are found for ""' which means that it search query is empty, I guess?
  
  ```
  {% set searchL = craft.request.getParam('loc') %}
      {% if searchL is not empty %}
        {% set queryParams = queryParams|merge({
          search: {
            query: 'klantLocation:' ~ searchL,
            subLeft: true,
            subRight: true,
          }
        }) %}
      {% endif %}
  
  ```
  
  I don't really know how to fix it, I've been looking through a lot of examples but I can't get it to work, any help would be appreciated
  
  **Tags:** search
  
  > **Comments:**
  > **username_1**: What type of field is klantLocation?  
  > **username_0**: @username_1 it's a plain text field  
  > **username_1**: You're sure `searchL` is what you're expecting it to be?  I'd also enable devMode, run the search, then find the SQL that's being generated in `craft/storage/runtime/logs` and make sure it looks correct for the data you're looking for.  
  > **username_0**: @username_1 Thank you, telling me to check the logs made me realise my field wasn't called 'klantLocation' but 'klantLocatie'. Pretty dumb mistake, but thank you for your time and help  
  > **username_1**: Glad you're all sorted!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-01-18. Score: 2 | Accepted answer
  
  I found the problem, which is pretty ridiculous but something that probably happens to other developers who are using multiple languages.. (I hope).
  
  In
  
  ```
  query: 'klantLocation:' ~ searchL,
  
  ```
  
  I had to replace `klantLocation` with `klantLocatie`
  
  Pretty dumb mistake but hopefully someone else will find some help in my mistake
  
  
  ---
  
  