choose solr documents where one field is great than another

限于喜欢 提交于 2019-12-21 05:23:07

问题


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.


回答1:


Finding all docs where date_A>date_B is not supported.

If you are only comparing data_A and date_B, then you could index another field date_a_greater_than_date_b:true for documents when date_A>date_B.




回答2:


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)



来源:https://stackoverflow.com/questions/9892716/choose-solr-documents-where-one-field-is-great-than-another

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