# Searching via querystring parameters with filters/conditions

**URL:** <https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518>\
**Category:** Elasticsearch\
**Created:** [January 27, 2012, 5:08am UTC](https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518 "2012-01-27T05:08:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish\_Pandit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_pandit/32/3000_2.png) [@Manish\_Pandit](https://discuss.elastic.co/u/Manish_Pandit)\
**Post date:** [January 27, 2012, 5:08am UTC](https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518/1 "2012-01-27T05:08:46Z")

</div>

Is it possible to filter search results using the query string  
parameters? For example, I want to search with any document that  
matches "John" but only want to retrieve the type "Employee". The  
documents have a field called documentType that can be, lets say,  
"Employee", "Employer", "Contractor".

This works great : [http://localhost:9200/persons/person?q:John](http://localhost:9200/persons/person?q:John)

But this doesnt:

[http://localhost:9200/persons/person?q:John&documentType:Employee](http://localhost:9200/persons/person?q:John&documentType:Employee).

This clearly has a code smell to it so I am sure I am doing something  
wrong, but wanted to check with this group if this is even possible  
without sending a JSON request to the server with filters, etc.

Thanks for the help!

-cheers,  
Manish

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 27, 2012, 6:13am UTC](https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518/2 "2012-01-27T06:13:00Z")

</div>

Try something like q:John%20+documentType:Employee

If it doesn't work, replace + by a %xx value

HTH  
David 😉  
@dadoonet

Le 27 janv. 2012 à 06:08, Manish Pandit [pandit.manish@gmail.com](mailto:pandit.manish@gmail.com) a écrit :

> Is it possible to filter search results using the query string  
> parameters? For example, I want to search with any document that  
> matches "John" but only want to retrieve the type "Employee". The  
> documents have a field called documentType that can be, lets say,  
> "Employee", "Employer", "Contractor".
> 
> This works great : [http://localhost:9200/persons/person?q:John](http://localhost:9200/persons/person?q:John)
> 
> But this doesnt:
> 
> [http://localhost:9200/persons/person?q:John&documentType:Employee](http://localhost:9200/persons/person?q:John&documentType:Employee).
> 
> This clearly has a code smell to it so I am sure I am doing something  
> wrong, but wanted to check with this group if this is even possible  
> without sending a JSON request to the server with filters, etc.
> 
> Thanks for the help!
> 
> -cheers,  
> Manish

---

<div class="post-metadata">

**Author:** ![Manish\_Pandit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_pandit/32/3000_2.png) [@Manish\_Pandit](https://discuss.elastic.co/u/Manish_Pandit)\
**Post date:** [January 27, 2012, 6:31am UTC](https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518/3 "2012-01-27T06:31:20Z")

</div>

Hi David - It worked - passing it on to my search team where they can  
validate my quick check further.

Thanks again!

-cheers,  
Manish

On Jan 26, 10:13 pm, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:

> Try something like q:John%20+documentType:Employee
> 
> If it doesn't work, replace + by a %xx value
> 
> HTH  
> David 😉  
> @dadoonet
> 
> Le 27 janv. 2012 à 06:08, Manish Pandit [pandit.man...@gmail.com](mailto:pandit.man...@gmail.com) a écrit :
> 
> > Is it possible to filter search results using the query string  
> > parameters? For example, I want to search with any document that  
> > matches "John" but only want to retrieve the type "Employee". The  
> > documents have a field called documentType that can be, lets say,  
> > "Employee", "Employer", "Contractor".
> 
> > This works great :[http://localhost:9200/persons/person?q:John](http://localhost:9200/persons/person?q:John)
> 
> > But this doesnt:
> 
> > [http://localhost:9200/persons/person?q:John&documentType:Employee](http://localhost:9200/persons/person?q:John&documentType:Employee).
> 
> > This clearly has a code smell to it so I am sure I am doing something  
> > wrong, but wanted to check with this group if this is even possible  
> > without sending a JSON request to the server with filters, etc.
> 
> > Thanks for the help!
> 
> > -cheers,  
> > Manish

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 27, 2012, 6:54am UTC](https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518/4 "2012-01-27T06:54:56Z")

</div>

Nice !

BTW, you can play with metadata : +\_type:myestype  
You can use also minus symbol : -\_type:myestype

Have a look at the Lucene query doc. There's so many very useful other combination.

David 😉  
@dadoonet

Le 27 janv. 2012 à 07:31, Manish Pandit [pandit.manish@gmail.com](mailto:pandit.manish@gmail.com) a écrit :

> Hi David - It worked - passing it on to my search team where they can  
> validate my quick check further.
> 
> Thanks again!
> 
> -cheers,  
> Manish
> 
> On Jan 26, 10:13 pm, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> 
> > Try something like q:John%20+documentType:Employee
> > 
> > If it doesn't work, replace + by a %xx value
> > 
> > HTH  
> > David 😉  
> > @dadoonet
> > 
> > Le 27 janv. 2012 à 06:08, Manish Pandit [pandit.man...@gmail.com](mailto:pandit.man...@gmail.com) a écrit :
> > 
> > > Is it possible to filter search results using the query string  
> > > parameters? For example, I want to search with any document that  
> > > matches "John" but only want to retrieve the type "Employee". The  
> > > documents have a field called documentType that can be, lets say,  
> > > "Employee", "Employer", "Contractor".
> > 
> > > This works great :[http://localhost:9200/persons/person?q:John](http://localhost:9200/persons/person?q:John)
> > 
> > > But this doesnt:
> > 
> > > [http://localhost:9200/persons/person?q:John&documentType:Employee](http://localhost:9200/persons/person?q:John&documentType:Employee).
> > 
> > > This clearly has a code smell to it so I am sure I am doing something  
> > > wrong, but wanted to check with this group if this is even possible  
> > > without sending a JSON request to the server with filters, etc.
> > 
> > > Thanks for the help!
> > 
> > > -cheers,  
> > > Manish

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:41am UTC](https://discuss.elastic.co/t/searching-via-querystring-parameters-with-filters-conditions/6518/5 "2017-07-06T03:41:18Z")

</div>

Closed on July 6, 2017, 3:41am UTC


