Answers.Body: <p>I'm not sure why your search is not working in this instance (though it might be because you're not executing the query, see my comment). But in general, fulltext search is way less precise, I would only do that if you need to support actual search terms. Since you're only filtering by categories and tags, I wouldn't search by category/tag titles, but instead use IDs to match the selected categories/tags directly. This will be way more precise, avoid edge-cases and will be much faster as well.</p>
  <p>First you'll need to adjust your form so the select fields use IDs instead of titles as their <code>value</code>:</p>
  <pre><code>{# category filter #}
  &lt;option value=&quot;{{ option.id }}&quot;&gt;{{ option.label }}&lt;/option&gt;
  
  {# tag filter #}
  &lt;option value=&quot;{{ tag.id }}&quot;&gt;{{ tag.title }}&lt;/option&gt;
  </code></pre>
  <p>Then adjust your query to query your <code>blogcategory</code> and <code>tags</code> field directly by ID:</p>
  <pre><code>{% set entries = craft.entries.section('blog') %}
  {% set blogcategory =  craft.request.getQuery('blogcategory') %}
  {% set tags =  craft.request.getQuery('tags') %}
  
  {% if blogcategory %}
      {% do entries.blogcategory(blogcategory) %}
  {% endif %}
  
  {% if tags %}
      {% do entries.tags(tags) %}
  {% endif %}     
  </code></pre>
  <p>Finally, make sure to actually execute the query:</p>
  <pre><code>{% for entry in entries.all() %}
      {# output results #}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-27T13:43:06.820Z
Answers.Text: Thanks! worked like charm beside one thing. {{ option.id }} was giving me an error so I stayed with the original code of {{ option.value }}.
Answers.UserDisplayName: LessMore Creative Studio
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-27T13:50:16.070Z
Answers.Text: Ah I see, I missed that you're accessing the field settings instead of the available categories. I guess the field settings have their options set in the format expected by the templates. Might be a bit more intuitive to query available categories/tags instead, in this case accessing the ID will work normally.
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-27T09:07:32.017Z
Answers.LastActivityDate: 2021-05-27T09:07:32.017Z
Answers.UserDisplayName: MoritzLost
Body: <p>*** Edited the question</p>
  <p>I have a code that used to work fine on Craft 2 and I don't understand what I need to change to make it work on Craft 3.</p>
  <p>I am using form to filter through a channel of entries based on two fields - checkbox field with handle <code>blogcategory</code> and tags field with handle <code>blogTags</code>.</p>
  <p>Here is the code of the form I am using for the filtering (worked perfectly on craft 2):</p>
  <pre><code>{% set blogcategory =  craft.request.getQuery('blogcategory') %}
  {% set tags =  craft.request.getQuery('tags') %}
  
  &lt;form action=&quot;&quot; method=&quot;get&quot;&gt;
      &lt;div class=&quot;filtering&quot;&gt;
  
          &lt;div class=&quot;section {% if blogcategory %}active{% endif %}&quot; &gt;
              &lt;span class=&quot;title&quot;&gt;category&lt;/span&gt;
              &lt;select name=&quot;blogcategory&quot;&gt;
                  &lt;option value=&quot;&quot;&gt;Any Category&lt;/option&gt;
                  {% for option in craft.fields.getFieldByHandle('blogcategory').settings.options %}
                      &lt;option value=&quot;{{ option.value }}&quot;&gt;{{ option.label }}&lt;/option&gt;
                  {% endfor %}
              &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class=&quot;section {% if tags %}active{% endif %}&quot;&gt;        
              &lt;span class=&quot;title&quot;&gt;tags&lt;/span&gt;
              &lt;select name=&quot;tags&quot;&gt;
                  &lt;option value=&quot;&quot;&gt;Any tags&lt;/option&gt;
                  {% for tag in craft.tags.group('blogTags') %}
                      &lt;option value=&quot;{{ tag.title }}&quot;&gt;{{ tag.title }}&lt;/option&gt;
                  {% endfor %}
              &lt;/select&gt;
          &lt;/div&gt;  
      &lt;/div&gt;
      &lt;div class=&quot;submit&quot;&gt;    
          &lt;input type=&quot;submit&quot; value=&quot;filter&quot;&gt;
      &lt;/div&gt;  
  &lt;/form&gt;
  </code></pre>
  <p>And here is the code for displaying the entries:</p>
  <pre><code>&lt;div class=&quot;container&quot;&gt; 
      {% set entries = craft.entries.section('blog') %}
      {% set search_terms = '' %}
      
      {% if blogcategory %}
          {% set search_terms = search_terms ~ ' blogcategory:' ~ blogcategory %}
      {% endif %}
  
      {% if tags %}
          {% set search_terms = search_terms ~ ' tags:' ~ tags %}
      {% endif %}
  
              
      {% if search_terms %}
          {% set entries = entries.search(search_terms) %}
      {% endif %}
      
      {% for entry in entries %}
          &lt;div class=&quot;thumb&quot;&gt;
              &lt;a href=&quot;{{ entry.url }}&quot;&gt;{{ entry.title }}&lt;/a&gt;
          &lt;/div&gt;
      {% endfor %}
  &lt;/div&gt;
  </code></pre>
  <p>The problem is that after submitting the form with the desired filtering, none of the entries are showing up at all. It seems like the <code>.serach</code> function is not working...</p>
  <p>I am a bit lost how to start understanding what fails under Craft 3...</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-27T07:28:27.390Z
Comments.Text: What have you tried to debug this? Are you getting any errors when you view the page with this template? What do the errors say? Any deprecation messages in the Utilities?
Comments.UserDisplayName: MoritzLost
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-27T08:44:14.770Z
Comments.Text: Thanks for the help. There are no error messages but the filtering doesn't work. For some reason, after submitting the form, none of the entries are showing up. It seems like the .search function is not working...
Comments.UserDisplayName: LessMore Creative Studio
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-27T08:54:53.077Z
Comments.Text: The first thing I'm noticing is that you're not executing the query. In Craft 3, you have to explicitly execute entry queries: `{% for entry in entries.all() %}`. Does this change anything?
Comments.UserDisplayName: MoritzLost
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-27T12:43:45.023Z
Comments.Text: Did all the tasks from Craft 2 to 3 run properly? As is, are your entries indexed properly? Does searching in your control panel work? If not, run `./craft resave/entries --update-search-index` ([docs](https://craftcms.com/docs/3.x/console-commands.html#resave-entries)).
Comments.UserDisplayName: Oli
Tags: <form><filtering>
Title: Filtering entires via tag field and checkbox field using a form
ThreadText: # Filtering entires via tag field and checkbox field using a form
  
  (Asked by: username_0 on 2021-05-26)
  
  \*\*\* Edited the question
  
  I have a code that used to work fine on Craft 2 and I don't understand what I need to change to make it work on Craft 3.
  
  I am using form to filter through a channel of entries based on two fields - checkbox field with handle `blogcategory` and tags field with handle `blogTags`.
  
  Here is the code of the form I am using for the filtering (worked perfectly on craft 2):
  
  ```
  {% set blogcategory =  craft.request.getQuery('blogcategory') %}
  {% set tags =  craft.request.getQuery('tags') %}
  
  <form action="" method="get">
      <div class="filtering">
  
          <div class="section {% if blogcategory %}active{% endif %}" >
              <span class="title">category</span>
              <select name="blogcategory">
                  <option value="">Any Category</option>
                  {% for option in craft.fields.getFieldByHandle('blogcategory').settings.options %}
                      <option value="{{ option.value }}">{{ option.label }}</option>
                  {% endfor %}
              </select>
          </div>
          <div class="section {% if tags %}active{% endif %}">        
              <span class="title">tags</span>
              <select name="tags">
                  <option value="">Any tags</option>
                  {% for tag in craft.tags.group('blogTags') %}
                      <option value="{{ tag.title }}">{{ tag.title }}</option>
                  {% endfor %}
              </select>
          </div>  
      </div>
      <div class="submit">    
          <input type="submit" value="filter">
      </div>  
  </form>
  
  ```
  
  And here is the code for displaying the entries:
  
  ```
  <div class="container"> 
      {% set entries = craft.entries.section('blog') %}
      {% set search_terms = '' %}
      
      {% if blogcategory %}
          {% set search_terms = search_terms ~ ' blogcategory:' ~ blogcategory %}
      {% endif %}
  
      {% if tags %}
          {% set search_terms = search_terms ~ ' tags:' ~ tags %}
      {% endif %}
  
              
      {% if search_terms %}
          {% set entries = entries.search(search_terms) %}
      {% endif %}
      
      {% for entry in entries %}
          <div class="thumb">
              <a href="{{ entry.url }}">{{ entry.title }}</a>
          </div>
      {% endfor %}
  </div>
  
  ```
  
  The problem is that after submitting the form with the desired filtering, none of the entries are showing up at all. It seems like the `.serach` function is not working...
  
  I am a bit lost how to start understanding what fails under Craft 3...
  
  **Tags:** form, filtering
  
  > **Comments:**
  > **username_1**: What have you tried to debug this? Are you getting any errors when you view the page with this template? What do the errors say? Any deprecation messages in the Utilities?  
  > **username_0**: Thanks for the help. There are no error messages but the filtering doesn't work. For some reason, after submitting the form, none of the entries are showing up. It seems like the .search function is not working...  
  > **username_1**: The first thing I'm noticing is that you're not executing the query. In Craft 3, you have to explicitly execute entry queries: `{% for entry in entries.all() %}`. Does this change anything?  
  > **username_2**: Did all the tasks from Craft 2 to 3 run properly? As is, are your entries indexed properly? Does searching in your control panel work? If not, run `./craft resave/entries --update-search-index` ([docs](https://craftcms.com/docs/3.x/console-commands.html#resave-entries)).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-05-27. Score: 2 | Accepted answer
  
  I'm not sure why your search is not working in this instance (though it might be because you're not executing the query, see my comment). But in general, fulltext search is way less precise, I would only do that if you need to support actual search terms. Since you're only filtering by categories and tags, I wouldn't search by category/tag titles, but instead use IDs to match the selected categories/tags directly. This will be way more precise, avoid edge-cases and will be much faster as well.
  
  First you'll need to adjust your form so the select fields use IDs instead of titles as their `value`:
  
  ```
  {# category filter #}
  <option value="{{ option.id }}">{{ option.label }}</option>
  
  {# tag filter #}
  <option value="{{ tag.id }}">{{ tag.title }}</option>
  
  ```
  
  Then adjust your query to query your `blogcategory` and `tags` field directly by ID:
  
  ```
  {% set entries = craft.entries.section('blog') %}
  {% set blogcategory =  craft.request.getQuery('blogcategory') %}
  {% set tags =  craft.request.getQuery('tags') %}
  
  {% if blogcategory %}
      {% do entries.blogcategory(blogcategory) %}
  {% endif %}
  
  {% if tags %}
      {% do entries.tags(tags) %}
  {% endif %}     
  
  ```
  
  Finally, make sure to actually execute the query:
  
  ```
  {% for entry in entries.all() %}
      {# output results #}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks! worked like charm beside one thing. {{ option.id }} was giving me an error so I stayed with the original code of {{ option.value }}.  
  > **username_1**: Ah I see, I missed that you're accessing the field settings instead of the available categories. I guess the field settings have their options set in the format expected by the templates. Might be a bit more intuitive to query available categories/tags instead, in this case accessing the ID will work normally.  
  
  ---
  
  