Searching via querystring parameters with filters/conditions


(Manish Pandit) #1

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

But this doesnt:

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


(David Pilato) #2

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

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

HTH
David :wink:
@dadoonet

Le 27 janv. 2012 à 06:08, Manish Pandit 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

But this doesnt:

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


(Manish Pandit) #3

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 wrote:

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

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

HTH
David :wink:
@dadoonet

Le 27 janv. 2012 à 06:08, Manish Pandit 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

But this doesnt:

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


(David Pilato) #4

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 :wink:
@dadoonet

Le 27 janv. 2012 à 07:31, Manish Pandit 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 wrote:

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

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

HTH
David :wink:
@dadoonet

Le 27 janv. 2012 à 06:08, Manish Pandit 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

But this doesnt:

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


(system) #5