Lucene OR查询不起作用 [英] Lucene OR query not working

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

问题描述

我正在尝试通过以下要求查询Solr: _我想获取所有没有特定字段的文件

I am trying to query Solr with following requirement: _ I would like to get all documents which not have a particular field

-排他性:[* TO *]

-exclusivity:[* TO *]

  • 我想获取所有具有此字段并获得特定值的文档
  • 排他性:(无)

    exclusivity:(None)

    因此,当我尝试使用以下命令查询Solr 4时:

    so when I am trying to query Solr 4 with:

    fq =(-排他性:[* TO *])或排他性:(无)

    fq=(-exclusivity:[* TO *]) OR exclusivity:(None)

    仅当文档中存在该字段且值为None时,我才得到结果,但结果不包含第一个查询的结果!

    I have only got results if the field exists in document and the value is None but results not contain results from first query !!

    我不明白为什么它不起作用

    I cannot understand why it is not working

    推荐答案

    我已经找到了解决此问题的方法.我错误地假设了-"在solr.I中的工作原理

    I have founded answer to this problem. I have made bad assumption how "-" works in solr.I though that

    -排他性:[* TO *]

    -exclusivity:[* TO *]

    将没有排他性字段的所有内容添加到数据集中,但事实并非如此. -"只能从数据集中排除内容.顺便说一句femtoRgon你是对的,但我将它用作fq(过滤器查询),而不是用作主查询,我忘了提到这一点.

    add everything without exclusivity field to the data set but it is not the case. The '-' could only exclude things from data set. BTW femtoRgon you are right but I am using it as fq (filter query) not as a master query I have forgotten to mention that.

    所以解决方案就像

    -排他性:([* * *和-(无))

    -exclusivity:([* TO *] AND -(None))

    完整查询看起来像

    /?q = *:*& fq =-排他性:([* TO *] AND-(None))

    /?q=*:*&fq=-exclusivity:([* TO *] AND -(None))

    所以这意味着我将获得所有不具有字段专有性或具有此字段的字段,并使用值None填充该字段.

    so that means I will get everything does not have field exclusivity or has this field and it is populated with value None.

    这篇关于Lucene OR查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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