在 solr 查询中使用 OR 和 NOT [英] using OR and NOT in solr query
问题描述
我正在处理类似于以下内容的 solr 查询:
I'm working on a solr query similar to the following:
((myField:superneat AND myOtherField:somethingElse) OR NOT myField:superneat)
运行此程序时,不会返回任何结果.在 OR NOT 的任一侧使用标准会返回我期望的结果 - 它们只是不能很好地协同工作.如果 myField 与 superneat 匹配,我还打算确保将 myOtherField 设置为 somethingElse,但如果 myField 不是 superneat,请将其包含在结果中.
When running this, no results are returned. Using criteria on either side of the OR NOT returns results that I'd expect - they are just not working well together. In the case that myField matches superneat, I'm intending to also ensure that myOtherField is set to somethingElse, but if myField is not superneat, include it in the results.
有人可以解释为什么 solr 不返回此类查询的结果吗?是否应该以某种方式重构查询 - 或者是否有不同的方式可以使用 solr 来实现所需的结果?
Can someone explain why solr is not returning results for this kind of query? Should the query be restructured somehow - or is there a different way in which solr can be used to achieve the desired result?
推荐答案
我不知道为什么这不起作用,但这个在逻辑上是等效的并且它确实工作:
I don't know why that doesn't work, but this one is logically equivalent and it does work:
-(myField:superneat AND -myOtherField:somethingElse)
也许这与在查询中两次定义相同的字段有关...
Maybe it has something to do with defining the same field twice in the query...
尝试在 solr-user group 中提问,然后发布回到这里最后的答案!
Try asking in the solr-user group, then post back here the final answer!
这篇关于在 solr 查询中使用 OR 和 NOT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!