solrsolr-query-syntax

Solr non-null query


What is the difference between the following two Solr queries, and which should be used when searching for null/non-null values?

fieldName:[* TO *]

fieldName:['' TO *]


Solution

  • They're practically the same. Use the first one as it's clearer about intent ([* TO *] is a common Solr pattern for referring to "everything that has a value).

    The second one expresses the same, it just says "give me everything from the empty token to anything" instead of "give me anything". In effect they should return the same result.