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 Kissue Kissue <ki...@gmail.com> on 2011/10/12 19:25:34 UTC

Search based on date

Hi

I am using solr 3.3 and solrJ. I have two date fields launch_date and
expiry_date. Now i want to be able to do a search for products that have not
expired. So basically i want to select products with launch_date < today AND
expiry_date > Today. Any pointers on how i can formulate such a query to
Solr?

Thanks.

Re: Search based on date

Posted by Chris Hostetter <ho...@fucit.org>.
http://www.lucidimagination.com/search/document/1f33fb9f68edee4c/date_range_query_where_doc_has_more_than_one_date_field

+launchDate:[* TO NOW/DAY] +expireDate:[NOW/DAY TO *]


: I am using solr 3.3 and solrJ. I have two date fields launch_date and
: expiry_date. Now i want to be able to do a search for products that have not
: expired. So basically i want to select products with launch_date < today AND
: expiry_date > Today. Any pointers on how i can formulate such a query to
: Solr?
: 
: Thanks.
: 

-Hoss

Re: Search based on date

Posted by Gora Mohanty <go...@mimirtech.com>.
On Wed, Oct 12, 2011 at 10:55 PM, Kissue Kissue <ki...@gmail.com> wrote:
> Hi
>
> I am using solr 3.3 and solrJ. I have two date fields launch_date and
> expiry_date. Now i want to be able to do a search for products that have not
> expired. So basically i want to select products with launch_date < today AND
> expiry_date > Today. Any pointers on how i can formulate such a query to
> Solr?

The today part would need to be handled by your front-end, but most languages
can easily do that. For the range query on the date, please see examples in
http://wiki.apache.org/solr/SolrQuerySyntax . More can also be found through
Google.

Regards,
Gora