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 Alex Cougarman <ac...@bwc.org> on 2012/09/13 15:03:45 UTC
Partial date searches
Hi. We're using Solr 4.0Beta and wondered how we can perform partial date searches. For example, we have this date stored in the index:
<date name="my_date">2010-05-12T00:00:00Z</date>
The user may want to search on all documents from 05-12 without providing the year. Or the user may want to search on 2010-xx-12 where the day isn't known but the month and year are known. Is this possible? Is there a sample search we can run in the admin interface against our index? Thanks.
Warm regards,
Alex Cougarman
Bahá'í World Centre
Haifa, Israel
Office: +972-4-835-8683
Cell: +972-54-241-4742
acougarm@bwc.org
Re: Partial date searches
Posted by Jack Krupansky <ja...@basetechnology.com>.
Selection of month "08" and day "01" would be:
date_text:????-08-01*
Or if you wanted month "08" OR day "01":
date_text:????-08* OR date_text:????-??-01*
-- Jack Krupansky
-----Original Message-----
From: Alex Cougarman
Sent: Sunday, September 16, 2012 7:59 AM
To: 'solr-user@lucene.apache.org'
Subject: RE: Partial date searches
Thank you for your great suggestion. That worked! A follow-up: We're using
this to do partial date searches on the copyField text field, providing
month "08" and day "01":
date_text:08* AND date_text:01*
It returns the results correctly, but is there a more efficient way to do
this? Thanks.
Warm regards,
Alex
-----Original Message-----
From: Jack Krupansky [mailto:jack@basetechnology.com]
Sent: 13 September 2012 4:47 PM
To: solr-user@lucene.apache.org
Subject: Re: Partial date searches
Wildcard patterns work on dates if they are "string" fields.
If your dates are "trie" dates (the default "date" field type now), you
would need to do a copyField to a string field to do the wildcard match.
Examples:
????-05-12*
2010-??-12*
-- Jack Krupansky
-----Original Message-----
From: Alex Cougarman
Sent: Thursday, September 13, 2012 9:03 AM
To: solr-user@lucene.apache.org
Subject: Partial date searches
Hi. We're using Solr 4.0Beta and wondered how we can perform partial date
searches. For example, we have this date stored in the index:
<date name="my_date">2010-05-12T00:00:00Z</date>
The user may want to search on all documents from 05-12 without providing
the year. Or the user may want to search on 2010-xx-12 where the day isn't
known but the month and year are known. Is this possible? Is there a sample
search we can run in the admin interface against our index? Thanks.
Warm regards,
Alex Cougarman
Bahá'í World Centre
Haifa, Israel
Office: +972-4-835-8683
Cell: +972-54-241-4742
acougarm@bwc.org
RE: Partial date searches
Posted by Alex Cougarman <ac...@bwc.org>.
Thank you for your great suggestion. That worked! A follow-up: We're using this to do partial date searches on the copyField text field, providing month "08" and day "01":
date_text:08* AND date_text:01*
It returns the results correctly, but is there a more efficient way to do this? Thanks.
Warm regards,
Alex
-----Original Message-----
From: Jack Krupansky [mailto:jack@basetechnology.com]
Sent: 13 September 2012 4:47 PM
To: solr-user@lucene.apache.org
Subject: Re: Partial date searches
Wildcard patterns work on dates if they are "string" fields.
If your dates are "trie" dates (the default "date" field type now), you would need to do a copyField to a string field to do the wildcard match.
Examples:
????-05-12*
2010-??-12*
-- Jack Krupansky
-----Original Message-----
From: Alex Cougarman
Sent: Thursday, September 13, 2012 9:03 AM
To: solr-user@lucene.apache.org
Subject: Partial date searches
Hi. We're using Solr 4.0Beta and wondered how we can perform partial date searches. For example, we have this date stored in the index:
<date name="my_date">2010-05-12T00:00:00Z</date>
The user may want to search on all documents from 05-12 without providing the year. Or the user may want to search on 2010-xx-12 where the day isn't known but the month and year are known. Is this possible? Is there a sample search we can run in the admin interface against our index? Thanks.
Warm regards,
Alex Cougarman
Bahá'í World Centre
Haifa, Israel
Office: +972-4-835-8683
Cell: +972-54-241-4742
acougarm@bwc.org
Re: Partial date searches
Posted by Jack Krupansky <ja...@basetechnology.com>.
Wildcard patterns work on dates if they are "string" fields.
If your dates are "trie" dates (the default "date" field type now), you
would need to do a copyField to a string field to do the wildcard match.
Examples:
????-05-12*
2010-??-12*
-- Jack Krupansky
-----Original Message-----
From: Alex Cougarman
Sent: Thursday, September 13, 2012 9:03 AM
To: solr-user@lucene.apache.org
Subject: Partial date searches
Hi. We're using Solr 4.0Beta and wondered how we can perform partial date
searches. For example, we have this date stored in the index:
<date name="my_date">2010-05-12T00:00:00Z</date>
The user may want to search on all documents from 05-12 without providing
the year. Or the user may want to search on 2010-xx-12 where the day isn't
known but the month and year are known. Is this possible? Is there a sample
search we can run in the admin interface against our index? Thanks.
Warm regards,
Alex Cougarman
Bahá'í World Centre
Haifa, Israel
Office: +972-4-835-8683
Cell: +972-54-241-4742
acougarm@bwc.org
Re: Partial date searches
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Well, you could always index the year/month/day separately. The query
might be a bit slower and more cumbersome, but it is doable. And for
indexing, you can probably use index-time transformers/components to
split the date into the parts behind the scenes.
The usual other option is to use Date Math, but I don't think it fits
your requirements.
http://lucene.apache.org/solr/api-4_0_0-BETA/org/apache/solr/util/DateMathParser.html
Regards,
Alex.
Personal blog: http://blog.outerthoughts.com/
LinkedIn: http://www.linkedin.com/in/alexandrerafalovitch
- Time is the quality of nature that keeps events from happening all
at once. Lately, it doesn't seem to be working. (Anonymous - via GTD
book)
On Thu, Sep 13, 2012 at 9:03 AM, Alex Cougarman <ac...@bwc.org> wrote:
> Hi. We're using Solr 4.0Beta and wondered how we can perform partial date searches. For example, we have this date stored in the index:
>
> <date name="my_date">2010-05-12T00:00:00Z</date>
>
> The user may want to search on all documents from 05-12 without providing the year. Or the user may want to search on 2010-xx-12 where the day isn't known but the month and year are known. Is this possible? Is there a sample search we can run in the admin interface against our index? Thanks.
>
> Warm regards,
> Alex Cougarman
>
> Bahá'í World Centre
> Haifa, Israel
> Office: +972-4-835-8683
> Cell: +972-54-241-4742
> acougarm@bwc.org
>