Where Are The Wise Men?

Mike's Ramblings

Formatting Date in Lucene Queries

| Comments

Little did I know that my adventures with Terracotta would soon require me to dip my toes into [Lucene][]so, you know, [we could actually find the objects in Terracotta.][]

So I had an odd problem where Lucene was only searching by the year. For example, I had an object with the date of 20090915. And so I made my date range as:

[bash]
datevalue:[19000101 TO 20091231]
[/bash]

And that worked fine. Then I changed the query to:

[bash]
datevalue:[20090101 TO 20091231]
[/bash]

And it didn't find it! Why not?

Even though it's not spelled out in the documentation, you have to use the [ISO Format for date/time objects.][] So I changed the query to:

[bash]
datevalue:[2009-01-01 TO 2009-12-31]
[/bash]

And it started working