On 6/17/2019 4:46 AM, Bram Biesbrouck wrote:
q={!parent which=-(parentUri:*)}*:*
Pure negative queries do not work in Lucene. Sometimes, when you do a
single-clause negative query, Solr is able to detect the problem and
automatically make an adjustment so the query works. This happens
transparently so you never notice.
In essence, what your negative query tells Lucene is "start with
nothing, and then subtract docs that match this query." Since you
started with nothing and then subtracted, you get nothing.
Also, that's a wilcard query. Which could be very slow if the possible
number of values in parentUri is more than a few. If that field can
only contain a very small number of values, then a wildcard query might
be fast.
The following query solves both problems -- starting with all docs and
then subtracting things that match the query clause after that:
*:* -parentUri:[* TO *]
This will return all documents that do not have the parentUri field
defined. The [* TO *] syntax is an all-inclusive range query.
Thanks,
Shawn