Mixing Solr range function with additional parameters

北城以北 提交于 2019-12-23 23:30:24

问题


I have a range function in a Solr fq that works as expected:

{!frange l=1 u=2}sum(termfreq(tags,'twitter'),termfreq(tags,'facebook'),termfreq(tags,'pinterest'))

However, if I try to further refine it by adding an additional parameter to the end:

{!frange l=1 u=2}sum(termfreq(tags,'twitter'),termfreq(tags,'facebook'),termfreq(tags,'pinterest')) AND (region:"US")

I get the error: org.apache.solr.search.SyntaxError: Unexpected text after function: AND (region:"US")

If I try to prepend an additional parameter:

(region:"US") AND {!frange l=1 u=2}sum(termfreq(tags,'twitter'),termfreq(tags,'facebook'),termfreq(tags,'pinterest'))

I get the error: org.apache.solr.search.SyntaxError: Expected ')' at position 27 in 'sum(termfreq(tags,'twitter''

I've tried wrapping the range portion in additional parenthesis but still having no luck. How can I combine a range function with additional query parameters?


回答1:


Ok I got solved what I need to. Basically, I was running commands from the Solr admin dashboard. Although I wasn't able to mix the frange command above with other queries in fq, I was able to put my frange command in q and keep the other queries in fq.

q: {!frange l=1 u=2}sum(termfreq(tags,'twitter'),termfreq(tags,'facebook'),termfreq(tags,'pinterest'))

fq: (region:"US") 

I answered a similar question here.

My issue is solved, but I'll leave this unanswered for a few days in case someone knows of a better way.




回答2:


Please check my answer here: Nested functional range query with OR

which solves this problem using query solr feature.




回答3:


You can also keep adding fq= parameters this is seen as an AND, for example:

&fq={!frange l=1 u=2}sum(termfreq(tags,'twitter'),termfreq(tags,'facebook'),termfreq(tags,'pinterest'))&fq=region:"US"


来源:https://stackoverflow.com/questions/16545115/mixing-solr-range-function-with-additional-parameters

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