On 1/24/2020 9:04 AM, David Hastings wrote:
just tried  "fq":"NOT year:[1900 TO 2000]"}},
on my data et and also worked as expected, mind if i ask why:
(u_lastLendingDate_combined_ls_ns:([8610134693 TO 8611935823]))

there are ()'s around your range query?

I think David is correct here about the parentheses causing a problem. If that query is working without the negation, that's a little odd. I do know the parentheses should not be there.

Purely negative queries in Lucene do not actually work. The problem with them is that if you start with nothing and then subtract something, you end up with nothing.

When the query being negated is very simple, Solr is able to detect the problem and internally fix it before running the query. If there is ANY complexity to it at all, Solr cannot do this, and it won't work. It is likely that adding parentheses around the range as you have makes the query complex enough that this detection doesn't work.

The fully correct way to write a negated version of the query above is:

*:* -u_lastLendingDate_combined_ls_ns:[8610134693 TO 8611935823]

This is a starting point of all documents, subtracting documents where the field falls within the specified range. You could replace the minus sign with "AND NOT " for the same effect.

Thanks,
Shawn

Reply via email to