Formatting Date in Lucene Queries
Sep 25th, 2009No 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:
datevalue:[19000101 TO 20091231]
And that worked fine. Then I changed the query to:
datevalue:[20090101 TO 20091231]
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:
datevalue:[2009-01-01 TO 2009-12-31]
And it started working
