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.Keyword("lastModified",DateField.dateToString(date));
Field field2 =
Field.Keyword("lastModified",DateField.dateToString(date));
Document doc1 = new Document();
doc1.add(field1);
Document doc2 = new Document();
doc2.add(field2);
RAMDirectory dir = new RAMDirectory();
IndexWriter writer = new IndexWriter(dir,new
StandardAnalyzer(),true);
writer.addDocument(doc1);
writer.addDocument(doc2);
writer.close();
IndexReader reader = IndexReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
QueryParser parser = new QueryParser("lastModified",new
StandardAnalyzer());
Query query = parser.parse("lastModified:[20020827 TO 20020827]");
System.out.println(searcher.explain(query,1));
System.out.println(searcher.explain(query,2));
Hits hits = searcher.search(query);
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
http://www.contextmedia.com/
----------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]