The following is the document I indexed into 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. 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. In this case the result should be null, but I am still getting the whole document as json in my output.
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
).
Then, Solr does not know null
value. 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):
q=definitionKey:bookshelf+-whword:[*+TO+*]
q=definitionKey:bookshelf+AND+NOT+whword:[*+TO+*]
q=definitionKey:bookshelf&fq=-whword:[*+TO+*]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.