Vuppala subbarao
Vuppala subbarao

Reputation: 23

How to pass multiple fq's with OR in SOLR

In solr, If we pass two fq's by default it will take it as AND, instead how to make it as or.

Thanks, Subbarao.

Upvotes: 2

Views: 3193

Answers (2)

Alexandre Rafalovitch
Alexandre Rafalovitch

Reputation: 9789

Solr 5.4 and later understands filter syntax in the body of main query (search for "filter(...)" on the page). So, you can do:

fq=filter(inStock:true) filter(price:[* TO 100])

You can also use variable substitutions to make these more readable by putting each filter into its own variable.

Several of these interesting concepts were well explained in the Hoss' presentation at Lucene/Solr Revolution 2016.

Upvotes: 3

MatsLindh
MatsLindh

Reputation: 52902

Filters are applied independently, so if you want to have an OR filter, you'll have to apply it inside a single filter:

fq=school:"srm" OR class:"first"

Upvotes: 2

Related Questions