Reputation:
In Solr, is it possible to search for all records in a given month regardless of the year or day ? For example, the snippet below would match everything on 01.01.2013 - what I want to do is find everything that appeared on 01.01 for any year.
date:2013-01-01T00:00:00Z
Upvotes: 1
Views: 1669
Reputation: 93676
No, not with a date field. Solr can only deal with ranges of dates, just like it only deals with ranges of numbers or ranges of strings. Asking Solr to only query a date field based on the first day of the month is like asking it to query on a numeric field and only give you odd numbers, or querying a string but only those starting with vowels.
What you'll need to do is break up the date into month and day components and then query on those. If your base field is sale_date
, you'll also need sale_month
and sale_day
. Then you can query on month:3
to get everything that happened in any March, or day:1
and get everything for the first day of any month or month:3 AND day:1
to get everything that happened on any March 1st.
Upvotes: 0