First, Solr does _not_ implement boolean logic. It can look like it, but that’s 
sugar. 
See: https://lucidworks.com/post/why-not-and-or-and-not/

As for (1), I haven’t a clue. If you’d provided the results of 
adding &debug=query to the query, the parsed version 
would have given us some pointers.

(2) Yes, See the reference above. the NOT (-) operator is really
“from the results so far, remove everything that satisfies this clause”.
But just -field_to_exclude:[* TO *] has nothing to remove
things that satisfy this clause _from_.


And a couple of nits:
There’s no need for the AND, again, see the reference above.
((*:* -field_to_exclude:*)) would work just fine.

Second, and just to confuse you, the *:* is not required in fq
clauses, there’s some special logic to handle
fq=-field_to_exclude:*
that implies the *:* that you’d have to put in a “q” clause.

Third, field_to_exclude:* is actually fairly inefficient, 
fq=-field_to_exclude:[* TO *]
can be more efficient. The reasons are rather arcane...

Best,
Erick

> On Sep 11, 2020, at 10:18 AM, Iana Bondarska <yana2...@gmail.com> wrote:
> 
> Hi everyone,
> I'm checking Solr query that contains condition "Exclude all documents that
> contain ceratin field".
> Currently, it looks like this:
> *(*:* AND -field_to_exclude:*)*
> 
> Full query is:
> *((some_other_field:"value") AND ((*:* AND -field_to_exclude:*)))*
> 
> If I use defType=edismax, nothing is found. If I use default defType - I
> get correct results, same as when I do not specify *:* in non-exists
> condition.
> 
> My questions are:
> 1) why defType "edismax" leads to empty results?
> 2) do we really need to include clause "**:**" in non-exists condition?
> Isn't *-field_to_exclude:* *enough?
> -- 
> Best Regards,
> Iana Bondarska

Reply via email to