Solr search query over multiple fields

jay picture jay · Nov 11, 2011 · Viewed 52.3k times · Source

Is it possible to search in Solr over two fields using two different words and get back only those results which contain both of them?

For example, if I have fields "type" and "location" , I want only those results who have type='furniture' and location = 'office' in them.

Answer

Jayendra picture Jayendra · Nov 11, 2011

You can use boolean operators and search on individual fields.

q=type:furniture AND location:office

If the values are fixed, it is better to use Filter Queries for Performance.

fq=type:furniture AND location:office