Nested functional range query with OR

左心房为你撑大大i 提交于 2020-01-05 02:54:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!