Reputation: 2252
I have SOLR Core with policy data, including two date fields: EffectiveDate and ExpirationDate.
I want to write a SOLR query that finds policies that, given a date d, were open on on that date so if this was SQL the WHERE clause would be: d BETWEEN EffectiveDate AND ExpirationDate
I would like to do this without changing the SOLR core
I have tried the following with no luck:
EffectiveDate[2020-01-01T00:00:00Z TO *] AND ExpirationDate[* TO 2020-01-01T00:00:00Z]
EffectiveDate:[2020-01-01T00:00:00Z TO *] AND ExpirationDate:[* TO 2020-01-01T00:00:00Z]
Upvotes: 0
Views: 90
Reputation: 52912
I think you've switched your intervals around.
EffectiveDate should be checked from any time until the datetime you're checking for, and expiration date from the current datetime to any time.
EffectiveDate:[* TO 2020-01-01T00:00:00Z] AND ExpirationDate:[2020-01-01T00:00:00Z TO *]
This will give you those that were active at 2020-01-01T00:00:00Z
.
Otherwise you'll only get those that had 2020-01-01T00:00:00Z
in both EffectiveDate
and ExpirationDate
.
Upvotes: 1