问题
I'm trying to do a functional query with an OR/AND however it seems there are limitations in doing so. Here is the logic for the SQL equivalent of the query I'm trying to perform:
ABS(col1-:val1)<1 OR (col1 IS NULL AND ABS(col2-:val1)<1)
Here is my current working fq query to grab the the documents with an ABS difference of <1.
fq={!frange l=0 u=1}abs(sub(col1,val1))
Here is what I'm trying to execute but can't without error
fq={!frange l=0 u=1}abs(sub(col1,val1)) OR (-col1:[* TO *] AND {!frange l=0 u=1}abs(sub(col2,val1)))
It seems like it's not possible to use and AND or and OR in the same fq when using a functional query. How would I go about doing this? I am using solr 4.1. Thanks
回答1:
Try
fq={!frange l=0 u=1 v=$myabs}&myabs=abs(sub(col1,val1))
回答2:
I stumbled upon similar issue and found out the solution. Posting it here so it might help somebody. The original query can be modified like this using query:"..." feature of solr:
fq=_query_:"{!frange l=0 u=1}abs(sub(col1,val1))" OR (-col1:[* TO *] AND _query_:"{!frange l=0 u=1}abs(sub(col2,val1)))"
来源:https://stackoverflow.com/questions/17516945/nested-functional-range-query-with-or