iamharish15
iamharish15

Reputation: 1850

Solr difference between having different query conditions in separate fq versus in single fq parameter

I am looking to make use of the Solr Filter Query Cache in an optimized manner. In this link, it is mentioned that each fq is cached separately and evaluated individually. But in the same example, the author uses the separate fq parameters for adding each filter query. For example: fq=color:black &fq=model:Lamborghini &fq=year:[2014 TO *]

So, my question is basically, instead of the above example, if I do this:

fq=color:black AND model:Lamborghini AND year:[2014 TO *]

Will it be the same as above in terms of how it caches the query? Will it still cache each query independently and evaluate them individually instead of the whole query (including AND)?

And finally, if I use the filter() method in the q section, then how to achieve the same result in that?

Upvotes: 0

Views: 51

Answers (1)

Persimmonium
Persimmonium

Reputation: 15771

If you do that, only an entry cache will be used, cached docs will be the ones that comply with all 3 clauses.

If the cardinality of your fields is large, and queries have several ANDS, then you might notice that if you use the 'fq the whole thing' approach might have less cache hits (cause it is less likely two q will use the same combinations over all fields), so in that case it might be preferrable to put each field in its own fq.

Upvotes: 2

Related Questions