I recently converted from Lucene 1.4.3 to 1.9.1 and in the process replaced all deprecated classes with the new ones as recommended (for forward compatibility with Lucene 2.0). This however seems to introduce an incompatibilty when the new timeToString() and stringToTime() classes are used. Using an index created with 1.4.3 and searched with 1.9.1 I now receive the following errors:

java.text.ParseException: Input is not valid date string: 0ehi17c0g
   at org.apache.lucene.document.DateTools.stringToDate(DateTools.java:140)
   at org.apache.lucene.document.DateTools.stringToTime(DateTools.java:110)
   at etc.., etc..

My 1.9.1 code is

when indexing:
long modDate = conn.getLastModified(); //the file's last modified date String longDate = DateTools.timeToString(modDate,DateTools.Resolution.MINUTE);
   indxDoc.add(new Field("longdate", longDate, Field.Store.YES,
   Field.Index.TOKENIZED));

when searching:

           Date d = new Date();
           try {
             d.setTime(stringToTime(longDate));
           } catch (ParseException e) {
             e.printStackTrace();
           }


My 1.4.3 code was:
when indexing:

String longDate = DateField.timeToString(modDate);
indxDoc.add(new Field("longdate", longDate, Field.Store.YES, Field.Index.TOKENIZED));

when searching:

Date d = new Date();
d.setTime(org.apache.lucene.document.DateField.stringToTime(longDate));

The problem does not occur if I both create and search the index with 1.9.1

I assume there is a better way to do this than the above code as this incompatibility is not documented. I know I can always revert to the old code in order to avoid re-creating the index, but I would prefer to find a solution that uses the latest classes AND avoids re-creating the index, if possible.
thanks for any help,

PS this is a re-transmission, I apologise if more than one copy is received, I had mail problems

_________________________________________________________________
realestate.com.au: the biggest address in property http://ninemsn.realestate.com.au


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to