Reza
Reza

Reputation: 363

Multiple Filter Queries with OR operation in Solr

I need to define multiple Filter Queries in my query but with OR operation. Imagine that there are fq1, fq2 and fq3. Now I would like my final filter query to be :

fq=fq1 AND fq2 OR fq3

Is there any way to handle it in Solr?

Upvotes: 11

Views: 10657

Answers (4)

F Lekschas
F Lekschas

Reputation: 12820

You can do something like this:

fq=fieldA:(valueA OR valueB) OR fieldB:valueC

Upvotes: 2

Zouzias
Zouzias

Reputation: 2360

It seems that now SOLR (>4.5) supports these type of queries, i.e.

fq=(field1:value1 OR field2:value2)

Upvotes: 8

brian519
brian519

Reputation: 318

This is not possible in Solr. It would be great if you could define your filter queries and then separately specify the boolean logic that should be applied between them.

A few years ago I created a Jira issue hoping to see this get added.

Upvotes: 2

ajreal
ajreal

Reputation: 47331

+fq:fq1 +(fq2:fq2 fq3:fq3) <-- if default query filter type is OR

Upvotes: -1

Related Questions