[英]solr search query with boolean parameter
The following is the document I indexed into solr: 以下是我索引到solr中的文档:
<doc>
<field name="definition">Bookshelf are to keep books. </field>
<field name="whword">what</field>
<field name="definitionKey">bookshelf</field>
</doc>
Now I need to query this document. 现在,我需要查询该文档。 But my requirement is to check if both
definitionkey
and whword
values are equals. 但是我的要求是检查
definitionkey
和whword
值是否相等。 The following is the query: 以下是查询:
http://localhost:8983/solr/faqcore/select?q=definitionKey:bookself&whword=null&wt=json
Now in this query, the value of whword
is null and this is not equal to the value in document. 现在,在此查询中,
whword
值为null,并且不等于document中的值。 In this case the result should be null, but I am still getting the whole document as json in my output. 在这种情况下,结果应该为null,但我仍在输出中将整个文档作为json获取。
Please provide your suggestion. 请提供您的建议。
First, you cannot add whword=null
as a request parameter, it has to be part of either query ( q
) or filter query ( fq
). 首先,您不能将
whword=null
添加为请求参数,它必须是查询( q
)或过滤器查询( fq
)的一部分。
Then, Solr does not know null
value. 然后,Solr不知道
null
值。 You have to specify a "negative" condition, either in query or in filter query. 您必须在查询或过滤器查询中指定一个“负”条件。 Condition to get documents with not empty
whword
is whword:[* TO *]
(mind the uppercase TO
!), so any of the following should work (I skip &wt=json
at the end of each variant): 获取不带空
whword
文档的条件是whword:[* TO *]
(注意大写的TO
!),因此以下任何一项都可以工作(我在每个变量的末尾都跳过了&wt=json
):
q=definitionKey:bookshelf+-whword:[*+TO+*]
q=definitionKey:bookshelf+AND+NOT+whword:[*+TO+*]
q=definitionKey:bookshelf&fq=-whword:[*+TO+*]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.