You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Kurt Nordstrom <ku...@unt.edu> on 2012/02/23 23:24:34 UTC

Date search by specific month and day

Hello all!

We have a situation involving date searching that I could use some 
seasoned opinions on. What we have is a collection of records, each 
containing a Solr date field by which we want search on.

The catch is that we want to be able to search for items that match a 
specific day/month. Essentially, we're trying to implement a "this day 
in history" feature for our dataset, so that users would be able to put 
in a date and we'd return all matching records from the past 100 years 
or so.

Is there a way to perform this kind of search with only the basic Solr 
date field? Or would I have parse out the month and day and store them 
in separate fields at indexing time?

Thanks for the help!

-Kurt

Re: Date search by specific month and day

Posted by Jan Høydahl <ja...@cominvent.com>.
I've seen this question several times on the list.
Perhaps it could be beneficial to create a new Date field that also soupports year-only, year-month, year-month-day etc queries? It could be called ExtendedDateField or something, and when indexing a date "YYYY-MM-DDTHH:mm:ssZ" it would individually store multiple versions in the index, perhaps using poly-field? It could work exactly like DateField for full date input, but also allow queries like myDate:2012, myDate:2012-03, myDate:2012-03-05, myDate:[1991 TO 2012] etc. 

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com
Solr Training - www.solrtraining.com

On 24. feb. 2012, at 03:52, Erick Erickson wrote:

> I think your best bet is to parse out the relevant units and index
> them independently. But this is probably only a few ints
> per record, so it shouldn't be much of a resource hog....
> 
> Best
> Erick
> 
> On Thu, Feb 23, 2012 at 5:24 PM, Kurt Nordstrom <ku...@unt.edu> wrote:
>> Hello all!
>> 
>> We have a situation involving date searching that I could use some seasoned
>> opinions on. What we have is a collection of records, each containing a Solr
>> date field by which we want search on.
>> 
>> The catch is that we want to be able to search for items that match a
>> specific day/month. Essentially, we're trying to implement a "this day in
>> history" feature for our dataset, so that users would be able to put in a
>> date and we'd return all matching records from the past 100 years or so.
>> 
>> Is there a way to perform this kind of search with only the basic Solr date
>> field? Or would I have parse out the month and day and store them in
>> separate fields at indexing time?
>> 
>> Thanks for the help!
>> 
>> -Kurt


Re: Date search by specific month and day

Posted by Erick Erickson <er...@gmail.com>.
I think your best bet is to parse out the relevant units and index
them independently. But this is probably only a few ints
per record, so it shouldn't be much of a resource hog....

Best
Erick

On Thu, Feb 23, 2012 at 5:24 PM, Kurt Nordstrom <ku...@unt.edu> wrote:
> Hello all!
>
> We have a situation involving date searching that I could use some seasoned
> opinions on. What we have is a collection of records, each containing a Solr
> date field by which we want search on.
>
> The catch is that we want to be able to search for items that match a
> specific day/month. Essentially, we're trying to implement a "this day in
> history" feature for our dataset, so that users would be able to put in a
> date and we'd return all matching records from the past 100 years or so.
>
> Is there a way to perform this kind of search with only the basic Solr date
> field? Or would I have parse out the month and day and store them in
> separate fields at indexing time?
>
> Thanks for the help!
>
> -Kurt