lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mile Rosu" <>
Subject RE: Best solution for the Date Range problem
Date Mon, 12 Jun 2006 11:49:44 GMT

You might consider using the suggestion at
We successfully used it to search for wide date ranges, on a relatively large number of date
Using this approach simplifies a lot the query you are suggesting (3). Gluing YYYY and MM
in a field like YYYYMM also would make your query look nicer.

Mile Rosu

-----Original Message-----
From: Björn Ekengren [] 
Sent: Monday, June 12, 2006 11:51 AM
Subject: Best solution for the Date Range problem

I would like users to be able to search on both terms and within a date
range. The solutions I have come across so far are:
1. Use the default QueryParser which will use RangeQuery which will expand
into a number of Boolean clauses. It is quite likely that this will run into
the TooManyClauses error.
2. Extend QueryParser and override getRangeQuery() and let it return a
FilteredQuery containing a RangeFilter.
3. Split Dates during indexing into YYYY, MM, DD and create a custom
RangeQuery that uses only the granularity needed:
  +date[20040830 TO 20060202]   
expands to 
(year:2004 AND month:08 AND day:30) OR
(year:2004 AND month:08 AND day:31) OR
(year:2004 AND month:09) OR 
(year:2004 AND month:10) OR 
(year:2004 AND month:11) OR 
(year:2004 AND month:12) OR
(year:2005) OR
(year:2006 AND month:01) OR
(year:2006 AND month:02 AND day:01) OR 
(year:2006 AND month:02 AND day:02)
Are there any other options, and which one is the best ?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message