Solr supports pure negative queries, but only at the top level. Pure
negative sub-queries are not supported. To work around this limitation your
need to add "*:*" to the sub-query:
(offTime:[2013-07-24T14:35:46.319Z TO *]) OR (*:* NOT offTime:[* TO *])
-- Jack Krupansky
-----Original Message-----
From: Paul Wellner Bou
Sent: Wednesday, July 24, 2013 11:29 AM
To: solr-user@lucene.apache.org
Subject: Unexpected search results with date range queries and OR
Dear Solr-list,
We are experimenting an unexpected behaviour of solr using date range
queries combined with OR. The use case is (reduced to this simple
example): We want to get all content which does not have the offTime
field defined or, if the offTime field is defined, it should be in the
future.
1) This query gives 1776 results: *
2) This query gives 707 results: (NOT offTime:[* TO *])
3) This query gives 1304 results: (offTime:[2013-07-24T14:35:46.319Z TO *])
Query 2 and 3 should not overlap at all, as 3) assumes something in
the field, any date from now on. And 2) searches all content whithout
any value in this field, is this correct?
Combining these two query with OR I would expect to get 1304+707
results, but comining them I get 1304 results. Not more. This is the
union query:
(offTime:[2013-07-24T14:35:46.319Z TO *]) OR (NOT offTime:[* TO *])
I tried this with additional filters as well to reduce the number of
items, and it seems that query 3) is overriding query 2) always, even
if query 2) returns much more results than query 3). I can reproduce
this, when adding such a filter:
Query 2) 118 results
Query 3) 1 result
Query 2) OR Query 3): 1 result
Are we doing something wrong?
Thank you and kind regards
Paul.