What is the syntax for choosing solr documents where one field is great than another?
More specifically, this is for two fields that contains dates.
If you do not specify a field in a query, Solr searches only the default field. Alternatively, you can specify a different field or a combination of fields in a query. To specify a field, type the field name followed by a colon ":" and then the term you are searching for within the field.
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).
Solr provides Query (q parameter) and Filter Query (fq parameter) for searching. The query (q parameter), as the name suggests, is the main query used for searching. Example. q = title:james. Filter queries are used alongside query (q parameter) to limit results of queries using additional filters.
I found this question looking for the same thing. As it turns out, you can filter by field comparisons using a filter query, particularly frange and sub.
frange
can take a lower bound l
or an upper bound u
, or both.
Optional values incl
and incu
inform the filter if the boundaries are inclusive or not.
sub
subtracts the literal numbers or document fields.
So the answer is to add a filter that accepts only those documents where A minus B is greater than zero. Set the lower bound to 0, omit the upper bound, and set incl
to false to exclude the lower bound itself (to remove documents where A==B)
fq={!frange l=0 incl=false}sub(A,B)
URL Encoded: fq=%7B!frange+l%3D0+incl%3Dfalse%7Dsub(A%2CB)
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