Hi Hoss, Below is the debug output for the query1. We have values for physical_city. It is not an empty valued field. when i said no-value, it was that the query does not have a value.
<lst name="debug"> <str name="rawquerystring">*business_name:Catherine AND physical_city:""* </str> <str name="querystring">business_name:Catherine AND physical_city:""</str> <str name="parsedquery"> (business_name:K0RN business_name:catherin)/no_coord </str> <str name="parsedquery_toString"*>**business_name:K0RN business_name:catherin*</str> Here , the query parser has skipped physical_city which had an empty value in the Query. Does this behavior hold for earlier versions of solr (like solr 3.5 or earlier ) On Tue, Aug 20, 2013 at 10:16 PM, Chris Hostetter <hossman_luc...@fucit.org>wrote: > > : Subject: Solr 4.4 Query ignoring null values > > First off: it's important that you understand there is no such thing as a > "null value" in a Solr index -- the concept does not exist. You can have > documents that "do not contain a value" for a field, and you can have > documents that contain "the empty string" as an indexed value, but there > is no such thing as querying for documents that have "null" indexed. > > : 1. > http://localhost:8180/solr/collection1/select?q=business_name:Catherine > : AND city:""&debugQuery=yes< > http://158.151.155.224:8180/solr/firstcollection/select?q=business_name:Catherine&fq=physical_city:%22%22&debugQuery=yes > > > : -> 100 results > : In this query , I can see the city has no value and solr is automatically > : omitting it. Does this feature included in the previous solr versions > also > > You haven't shown us the output, so we can only guess as to what you mean > by "the city has no value" (no value where? in the query string? in the > debug output? in the stored fields of the results?) > > I suspect that what's happening is this... > > * your city field is a TextField with an analyzer that produces no tokens > for the input string "" > * that means that the "city" clause of your query is a No-Op and the 100 > results you get are just teh 100 docs that match "business_name:Catherine" > > : 3. http://localhost:8180/solr/collection1/select?q=< > http://158.151.155.224:8180/solr/firstcollection/select?q=business_name:Catherine&fq=physical_city:%22%22&debugQuery=yes > > > : business_name:Catherine< > http://158.151.155.224:8180/solr/firstcollection/select?q=business_name:Catherine&fq=physical_city:%22%22&debugQuery=yes > >&fq=city:"" > : -> 0 Results. If the first query works, why not the third? > > In the first query, you have a No-Op 2nd clause -- not just a clause that > doesn't match anything, but a clause that actually doesn't *mean* anything > because the empty string doesn't produce any tokens from your analyzer, so > it gets dropped by the query parser because there is no query to build > from it -- but there is still the 1st clause which has meaning -- so as > a result it is possible for documents to match that query, and 100 > documents do match. > > In your 3rd URL you have a query (it happens to be an fq (filter query) > but that's not important to the point) consisting of a single clause which > is a No-Op -- so the resulting query is incapable of matching any > documents. > > ... > > If you want to be able to index documents containing the empty string ("") > as a value, and then search for documents containing that value -- you > need to use a field type / analyzer that respects and preserves the empty > string as a legal field value. > > If however you want to query (or filter) against documents that have a > value, you should either: > > * index a special boolean field "has_city" > * filter on a range query over all values, ie... > * fq=city:[* TO *] > * fq=-city:[* TO *] > > > -Hoss >