lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: sorting by date (XML)
Date Tue, 27 Apr 2004 19:58:36 GMT
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).

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message