在solr查询中使用OR和NOT [英] using OR and NOT in solr query

查看:794
本文介绍了在solr查询中使用OR和NOT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究类似于以下内容的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用户组中询问,然后发布回到这里,最后的答案!

Try asking in the solr-user group, then post back here the final answer!

这篇关于在solr查询中使用OR和NOT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆