lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Wilkicki" <>
Subject Problem with Date Range search
Date Fri, 14 Nov 2003 00:42:25 GMT
Hi all!

I'm having a problem with searching dates.  I created two documents with the
same date, 08/27/2002, in a lastModified field and then try and search a
range lastModified:[20020827 TO 20020827] (Other, wider ranges, don't seem
to help).  My understanding is that this should return my two documents
because the range is inclusive.  As a related aside, I can't seem to get any
range to work properly at all.  Here is a snippet of code describing what
I'm doing:

	  DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

        Date date = formatter.parse("2002-08-27");

        Field field1 =

        Field field2 =

        Document doc1 = new Document();


        Document doc2 = new Document();

        RAMDirectory dir = new RAMDirectory();

        IndexWriter writer = new IndexWriter(dir,new



        IndexReader reader =;

        IndexSearcher searcher = new IndexSearcher(reader);

        QueryParser parser = new QueryParser("lastModified",new

        Query query = parser.parse("lastModified:[20020827 TO 20020827]");


        Hits hits =;

The explanations read as follows:

NaN = product of:
  0.0 = sum of:
  NaN = coord(0/0)

NaN = product of:
  0.0 = sum of:
  NaN = coord(0/0)

I have checked, and the directory does have 2 documents in it when I search.
I have also echoed the Date objects out and the DateFormat seems to be
parsing the date correctly.  I am using Lucene 1.3 RC1.  Any insight into
what I'm doing wrong here would be great.

Thanks in advance.

Joseph Wilkicki
Software Engineer
Context Media, Inc.
Providence, RI

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

View raw message