开发者

Remove Expired Records in solr query syntax

开发者 https://www.devze.com 2022-12-22 02:07 出处:网络
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 r

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


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 *])


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号