【发布时间】:2013-05-20 13:35:00
【问题描述】:
对于 Solr 中的过滤器查询,我需要包含所有非特定类型的文档,以及在特定字段中具有值的该类型的任何文档。
我试过了:
fq=(-type_id:(A) OR content:(['' TO *]))
但不包括type_id B、C 等具有空content 的文档。 (type_id 是 string 字段,content 是 text。)
我看过这个问题:Complex SOLR query including NOT and OR 和这篇关于运营商的帖子:http://robotlibrarian.billdueber.com/2011/12/solr-and-boolean-operators/。我认为我的语法应该是正确的。谁能看到我的错误?
更新:我正在使用 LuceneQParser。它将上面的过滤查询解析为
-type_id:A content:['' TO *]
它将 cmets (-type_id:A OR (content:[* TO *] AND type_id:A)) 中建议的过滤查询解析为
-type_id:A (+content:[* TO *] +type_id:A)
所以没有结果。
【问题讨论】:
-
你想达到什么目的?? type_id 不是 A 或所有没有内容或某些内容的文档?
-
@Jayendra 看我问题的第一句话:对非 type_id=A 的文档没有限制;如果它们是 type_id=A,它们应该有非空内容。例如,我也尝试过
fq=((type_id:(A) AND content:(['' TO *])) OR type_id:(*)),但仍然没有运气。 -
你可以试试 fq=-type_id:A OR (content:[* TO *] AND type_id:A)
-
@Jayendra 我尝试了您对过滤器查询的建议;现在我没有得到任何结果。请在我更新的问题中查看查询解析器信息。
标签: search solr filter boolean