<p>Have you checked that the custom fields are searchable by having the &quot;Use this field’s values as search keywords&quot; option checked? The value will be added to the index only after this is checked and the entry is saved. You can also <a href="https://craftcms.com/docs/3.x/searching.html#rebuilding-your-search-indexes" rel="nofollow noreferrer">rebuild the search index</a> with a console command.</p>
<pre class="lang-sh prettyprint-override"><code>php craft resave/entries --update-search-index
</code></pre>
<p>I'd also recommend sticking to one syntax for the query, rather than mixing them, for ease of use.</p>
<pre><code>{% set entryQuery = craft.entries().section('appeals') %}

{% set searchQuery = craft.app.request.getParam('q') %}
{% if searchQuery %}
    {% do entryQuery.search('appealer:' ~ searchQuery ~ ' OR  assigner:' ~ searchQuery ~ ' OR  title:' ~ searchQuery) %}
{% endif %}

{% set entries = entryQuery.all() %}
</code></pre>

CC BY-SA 4.0
2021-07-06T07:54:38.707Z
2021-07-06T07:54:38.707Z
Ben Croker
<p>I would like to use a query term for multiple fields according to their fields' handle in Craft cms 3.5.x, but unfortunately only for field title that works correctly, while for the other fields i get no results at all. Additionally i have also tried another <a href="https://stackoverflow.com/questions/68243792/craft-cms-search-multiple-fields-with-query-parameter">method here</a> without success.</p>
<pre><code>            &lt;h1&gt;Search Results&lt;/h1&gt;
           
            {% set queryParams = {} %}

            {% if craft.app.request.getParam('q') %}
                {% set searchQuery = craft.app.request.getParam('q') %}
                {% set queryParams = queryParams|merge({
                    search:{
                          query: 'appealer:' ~ searchQuery ~ ' OR  assigner:' ~ searchQuery ~ ' OR  title:' ~ searchQuery,
                        }
                       }) %}
                {% set queryEntries = craft.entries(queryParams).section('appeals') %}      

            {% endif %}

                {% if queryEntries|length %}
                  &lt;p&gt;{{ queryEntries|length }} results:&lt;/p&gt;

                  &lt;ol&gt;
                    {% for entry in queryEntries %}
                      &lt;li&gt;&lt;a href=&quot;{{ entry.url }}&quot;&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
                    {% endfor %}
                  &lt;/ol&gt;
                {% else %}
                  &lt;p&gt;Your search for “{{ searchQuery }}” didn’t return any results.&lt;/p&gt;
                {% endif %}
</code></pre>
<p>Any idea that could help me?</p>
<p>Regards</p>

<search><filter>
Search on multiple custom fields with a query parameter
# Search on multiple custom fields with a query parameter

(Asked by: username_0 on 2021-07-04)

I would like to use a query term for multiple fields according to their fields' handle in Craft cms 3.5.x, but unfortunately only for field title that works correctly, while for the other fields i get no results at all. Additionally i have also tried another method here without success.
            Search Results
           
            {% set queryParams = {} %}

            {% if craft.app.request.getParam('q') %}
                {% set searchQuery = craft.app.request.getParam('q') %}
                {% set queryParams = queryParams|merge({
                    search:{
                          query: 'appealer:' ~ searchQuery ~ ' OR  assigner:' ~ searchQuery ~ ' OR  title:' ~ searchQuery,
                        }
                       }) %}
                {% set queryEntries = craft.entries(queryParams).section('appeals') %}      

            {% endif %}

                {% if queryEntries|length %}
                  {{ queryEntries|length }} results:

                  
                    {% for entry in queryEntries %}
                      {{ entry.title }}
                    {% endfor %}
                  
                {% else %}
                  Your search for “{{ searchQuery }}” didn’t return any results.
                {% endif %}

Any idea that could help me?
Regards

**Tags:** search, filter

---

## 1 answers

### Answer by username_1 on 2021-07-06. Score: 2

Have you checked that the custom fields are searchable by having the "Use this field’s values as search keywords" option checked? The value will be added to the index only after this is checked and the entry is saved. You can also rebuild the search index with a console command.
php craft resave/entries --update-search-index

I'd also recommend sticking to one syntax for the query, rather than mixing them, for ease of use.
{% set entryQuery = craft.entries().section('appeals') %}

{% set searchQuery = craft.app.request.getParam('q') %}
{% if searchQuery %}
    {% do entryQuery.search('appealer:' ~ searchQuery ~ ' OR  assigner:' ~ searchQuery ~ ' OR  title:' ~ searchQuery) %}
{% endif %}

{% set entries = entryQuery.all() %}


---

