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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to