views:

208

answers:

1

Hi,

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

+2  A: 

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
Wicked.. that totally works. Thank you. I already have a field i can use which doesn't change. +1
CraftyFella
Do you think this is a bug in Solr? Or am i just not using the syntax correctly?
CraftyFella