Devour
Devour

Reputation: 335

SOLR daterange with no or infinite end_date

I'm new to SOLR and I have an issue with a query for a daterange with no end_date. For non-null end_date it works fine. However, I want to get all users who have come today or earlier and who don't have the end_date or (start_date = end_date). But I don't obtain any expected users. Will appreciate any help.

Tried to use type="string" and type="date".

My schema:

<field name="startDate" type="date" indexed="true" stored="true" required="false" multiValued="true" />

<field name="endDate" type="date" indexed="true" stored="true" required="false" multiValued="true" />

My query is: ?q=startDate:[* TO NOW] AND endDate:[NOW TO *]

Also tried: ?q=startDate:[* TO NOW] AND endDate:[NOW TO *:*]

Upvotes: 0

Views: 169

Answers (1)

OanaB
OanaB

Reputation: 339

I think that this is the answer you are looking for:

q

start_date:[* TO NOW] AND (end_date:[NOW TO *] OR  (*:* NOT end_date:*) )

Upvotes: 2

Related Questions