lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Koberg <>
Subject Re: sorting by date (XML)
Date Tue, 27 Apr 2004 20:26:05 GMT
Erik Hatcher wrote:

> On Apr 27, 2004, at 3:41 PM, Robert Koberg wrote:
>> Oops, I meant to write DateField.timeToString which I use when 
>> querying. If I use DateField.dateToString when indexing but 
>> timeToString when searching is that a bad practice? I do only need 
>> month, day and year. So should I be indexing with timeToString?
>> How would you do it if the above is still a bad practice?
>> Sorry for the basic questions...
> No worries.  This is the type of thing that is a "gotcha" with dates, 
> and is a prime candidate for a wiki page (nudge, nudge)...
> You should represent dates (at index and search time) using YYYYMMDD 
> format - it needs to be lexicographically ordered.  Forget DateField and 
> Field.Keyword(String,Date) altogether.
> Some tricks are needed if you need to use QueryParser to translate 
> mm/dd/yyyy format to how you represent it, but it is quite simple. 
> (subclass QueryParser, override getRangeQuery).

Ah. Great - thanks! I see you added it to the wiki. Thanks again :)

This is perfect in my case since iso8601 is in the format:


Luckily so far, from my logs, hardly anyone uses the date search. I 
guess I should have been doing this from the beginning, don't know why I 


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

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

View raw message