1

I'm having a solr query syntax issue (I think) with solr 1.4. I'm trying exclude expired records from a solr query. However if the record doesn't have an expiry record, i would like to bring that record back also. E.g.

To only get a list of record that haven't expired i am using this query:

expirydate:[NOW/DAY TO *]

Then I thought to get a list of records which don't have an expiry date i can use

-expirydate:[* TO *]

Both queries work on their own. I.e. the first query brings back 3 records. The 2nd query brings back 921 records. However when I combine the 2 queries together with an OR I get 0 records:

expirydate:[NOW/DAY TO *] OR -expirydate:[* TO *]

Any ideas what I'm doing wrong?

Thanks

Dave

CraftyFella
  • 7,520
  • 7
  • 47
  • 61

2 Answers2

2

Not 100% sure here, but I don't think you can combine OR with the negation operator in this manner.

Try adding a dummy field with the same value in every document and try

enddate:[NOW/DAY TO *] OR (dummy:yes -enddate:[* TO *])
bajafresh4life
  • 12,491
  • 5
  • 37
  • 46
1

I just had to tackle this problem, I went about implementing the approved answer but then realized that I could just do this:

-expired-date:[* TO NOW]

That worked regardless if the document had expired-date set.

Squeee123
  • 906
  • 5
  • 6