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?
Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter. The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially). Follow this answer to receive notifications.
The correct way is the copyField you have and declaring the field all as the default search field. That's how the examples that ship with Solr out of the box do it. Excellent, adding <str name="df">all</str> to defaults in solrconfig. xml indeed solved this.
The Extended DisMax (eDisMax) query parser is an improved version of the DisMax query parser. In addition to supporting all the DisMax query parser parameters, Extended Dismax: supports the full Lucene query parser syntax. supports queries such as AND, OR, NOT, -, and +.
The defType Parameter The defType parameter selects the query parser that Solr should use to process the main query parameter ( q ) in the request. For example: defType=dismax. If no defType param is specified, then by default, the The Standard Query Parser is used. ( eg: defType=lucene )
It seems that now SOLR (>4.5) supports these type of queries, i.e.
fq=(field1:value1 OR field2:value2)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With