<p>You'd have to set up an ElementCriteriaModel with parameters adapted to your entry type and the values you're getting from the query string.</p>

<p>I'd recommend to read the official docs on that topic</p>

<p><a href="https://craftcms.com/docs/templating/elementcriteriamodel" rel="nofollow">https://craftcms.com/docs/templating/elementcriteriamodel</a><br>
<a href="https://craftcms.com/docs/templating/craft.entries" rel="nofollow">https://craftcms.com/docs/templating/craft.entries</a></p>

<p>After that you shouldn't miss <a href="http://webstoemp.com/blog/combined-searches-and-filters-craft-cms/" rel="nofollow">Combined searches and filters using Craft</a> on Webstoemp's blog, a great introduction to setting up search forms and "filtering" the results with the ElementCriteriaModel.</p>

CC BY-SA 3.0
2016-03-29T13:50:38.670Z
Thankyou @carlcs managed to figure it out from the documentation and seeing Webstoemp's example.
Adam Ascroft
CC BY-SA 3.0
2016-03-26T01:47:01.450Z
2016-03-26T01:47:01.450Z
carlcs
<p>I believe that Craft searches and indexes the contents from ALL custom fields. If that's true, then you only need a single search field. e.g.</p>

<p><a href="https://craftcms.com/search?q=field" rel="nofollow">https://craftcms.com/search?q=field</a></p>

<p>Display's results from multiple Sections i.e. <strong>Plugin Dev</strong>, <strong>Documentation</strong> and <strong>Templating</strong></p>

<p>Would you consider separating your search results, based on whichever entries/sections are returned by the search query.</p>

<p>Hope that helps</p>

CC BY-SA 3.0
2016-03-25T13:38:57.777Z
2016-03-25T13:38:57.777Z
Matt P
<p>As you can see in the code below I'm currently searching for the keyword but how can I make it so it picks up on entries that have a matching keyword, location &amp; salary or if they don't fill out one of the fields then just search using the remaining fields.</p>

<pre><code>{% set keywordQuery = craft.request.getParam('keyword') %}
{% set locationQuery = craft.request.getParam('location') %}
{% set salaryQuery = craft.categories.getParam('salary') %}

{% set entries = craft.entries.search(keywordQuery).order('score') %}

&lt;form action="{{ url('jobs/list') }}" class="submit-this"&gt;
     &lt;ul&gt;
         &lt;li&gt;
             &lt;input type="text" name="keyword" placeholder="Keyword"&gt;
         &lt;/li&gt;
         &lt;li&gt;
             &lt;input type="text" name="location" placeholder="Town, City, Postcode"&gt;
         &lt;/li&gt;
         &lt;li class="select"&gt;
              &lt;select name="salary"&gt;
                   {% for category in craft.categories.group('salary') %}
                         &lt;option value="{{ category.slug }}"&gt;{{ category.title }}&lt;/option&gt;
                   {% endfor %}
              &lt;/select&gt;
         &lt;/li&gt;
         &lt;li&gt;
              &lt;input type="submit" name="search" value="Search" class="form-submit"&gt;
         &lt;/li&gt;
    &lt;/ul&gt;
&lt;/form&gt;

{% for entry in entries %}

    &lt;div class="entry-section{% if loop.index is even %} grey{% endif %}"&gt;
        &lt;div class="content"&gt;
            &lt;h3&gt;
                {{ entry.title }}
            &lt;/h3&gt;
            {{ entry.jobsExcerpt }}
            &lt;div class="footer"&gt;
                &lt;ul&gt;
                    {% for block in entry.location %}
                        &lt;li&gt;
                            &lt;img src="{{ block.icon.first().url }}"&gt;
                            &lt;span&gt;
                                {% for category in block.category.limit(1) %}
                                    {{ category.title }}
                                {% endfor %}
                            &lt;/span&gt;
                        &lt;/li&gt;
                    {% endfor %}    
                    {% for block in entry.salary %}
                        &lt;li&gt;
                            &lt;img src="{{ block.icon.first().url }}"&gt;
                            &lt;span&gt;
                                {% for category in block.category.limit(1) %}
                                    {{ category.title }}
                                {% endfor %}
                            &lt;/span&gt;
                        &lt;/li&gt;
                    {% endfor %}
                    {% for block in entry.keyword %}    
                        &lt;li&gt;
                            &lt;img src="{{ block.icon.first().url }}"&gt;
                            &lt;span&gt;
                                {% for category in block.category.limit(1) %}
                                    {{ category.title }}
                                {% endfor %}
                            &lt;/span&gt;
                        &lt;/li&gt;
                    {% endfor %}    
                &lt;/ul&gt;
            &lt;/div&gt;
        &lt;/div&gt;  
        &lt;div class="side-bar"&gt;
            &lt;a href="{{ entry.url }}" class="button"&gt;
                Apply
            &lt;/a&gt;
        &lt;/div&gt;
    &lt;/div&gt;

{% endfor %}    
</code></pre>

<p>I just can't seem to figure it out, any help would be much appreciated.</p>

<p>Thanks.</p>

<search><craft-features><query>
Searching multiple queries using CraftCMS search function
# Searching multiple queries using CraftCMS search function

(Asked by: username_0 on 2016-03-23)

As you can see in the code below I'm currently searching for the keyword but how can I make it so it picks up on entries that have a matching keyword, location & salary or if they don't fill out one of the fields then just search using the remaining fields.
{% set keywordQuery = craft.request.getParam('keyword') %}
{% set locationQuery = craft.request.getParam('location') %}
{% set salaryQuery = craft.categories.getParam('salary') %}

{% set entries = craft.entries.search(keywordQuery).order('score') %}


     
         
             
         
         
             
         
         
              
                   {% for category in craft.categories.group('salary') %}
                         {{ category.title }}
                   {% endfor %}
              
         
         
              
         
    


{% for entry in entries %}

    
        
            
                {{ entry.title }}
            
            {{ entry.jobsExcerpt }}
            
                
                    {% for block in entry.location %}
                        
                            
                            
                                {% for category in block.category.limit(1) %}
                                    {{ category.title }}
                                {% endfor %}
                            
                        
                    {% endfor %}    
                    {% for block in entry.salary %}
                        
                            
                            
                                {% for category in block.category.limit(1) %}
                                    {{ category.title }}
                                {% endfor %}
                            
                        
                    {% endfor %}
                    {% for block in entry.keyword %}    
                        
                            
                            
                                {% for category in block.category.limit(1) %}
                                    {{ category.title }}
                                {% endfor %}
                            
                        
                    {% endfor %}    
                
            
          
        
            
                Apply
            
        
    

{% endfor %}    

I just can't seem to figure it out, any help would be much appreciated.
Thanks.

**Tags:** search, craft-features, query


---

## 2 answers

### Answer by username_1 on 2016-03-26. Score: 3 | Accepted answer

You'd have to set up an ElementCriteriaModel with parameters adapted to your entry type and the values you're getting from the query string.

I'd recommend to read the official docs on that topic

<https://craftcms.com/docs/templating/elementcriteriamodel>  
<https://craftcms.com/docs/templating/craft.entries>

After that you shouldn't miss [Combined searches and filters using Craft](http://webstoemp.com/blog/combined-searches-and-filters-craft-cms/) on Webstoemp's blog, a great introduction to setting up search forms and "filtering" the results with the ElementCriteriaModel.

> **Comments:**
> **username_0**: Thankyou @username_1 managed to figure it out from the documentation and seeing Webstoemp's example.  

---

### Answer by username_2 on 2016-03-25. Score: 2

I believe that Craft searches and indexes the contents from ALL custom fields. If that's true, then you only need a single search field. e.g.

<https://craftcms.com/search?q=field>

Display's results from multiple Sections i.e. **Plugin Dev**, **Documentation** and **Templating**

Would you consider separating your search results, based on whichever entries/sections are returned by the search query.

Hope that helps


---

