Dear community! It works as suggested, either using
"-u_lastLendingDate_combined_ls_ns:[8610134693 TO 8611935823]" or "NOT u_lastLendingDate_combined_ls_ns:[8610134693 TO 8611935823]" It seems that additional bracketing (as in the next line) does not harm my query but I will eliminate it as it's unnecessary and possibly wrong. "!u_lastLendingDate_combined_ls_ns:([8610134693 TO 8611935823])"] About the only negated query-parts, thanks I already thought of that! Glad I already have a positive part with "u_id_s:[* TO *]" I am not sure about my initial mistake, either my positioning of the negate-keyword was wrong, or I did not spell the "NOT"-keyword in uppercase. Thank you all for your time and effort, have a nice day! Sebastian -----Ursprüngliche Nachricht----- Von: Shawn Heisey [mailto:apa...@elyograg.org] Gesendet: Freitag, 24. Jänner 2020 21:51 An: solr-user@lucene.apache.org Betreff: Re: How to negate numeric range query - or - how to get records NOT matching a certain numeric range 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