lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charlie Hubbard <charlie.hubb...@gmail.com>
Subject Converting Older indexes and NumericField?
Date Thu, 22 Sep 2011 21:11:42 GMT
Hi,

I have an existing index from v.2.2 that I populated with documents that had
Fields before NumericField was created.  I'm upgrading my program to v3.0,
and I'd like to change my RangeQuery to use the NumericRangeQuery or
NumericRangeFilter.  Here is how I stored my fields:

        document.add( new Field( "dateSent", DateTools.dateToString(
dateSent, DateTools.Resolution.HOUR ), Field.Store.NO, Field.Index.ANALYZED
) );
        document.add( new Field( "dateArchived-stored",
DateTools.dateToString( dateArchived, DateTools.Resolution.MILLISECOND ),
Field.Store.YES, Field.Index.NOT_ANALYZED ) );

        document.add( new Field( "dateArchived", DateTools.dateToString(
dateArchived, DateTools.Resolution.HOUR ), Field.Store.NO,
Field.Index.ANALYZED ) );
        document.add( new Field( "dateSent-stored", DateTools.dateToString(
dateSent, DateTools.Resolution.MILLISECOND), Field.Store.YES,
Field.Index.NOT_ANALYZED ) );

The dateArchived-stored, and dateSent-stored were added so I could
reconstitute the exact dates to milliseconds, but I reduced my potential
terms in the field by storing my dates only to hourly precision to get
better performance.  If I use NumericRangeQuery/NumericRangeFilter do I have
to change those fields to be indexed like:

        document.add( new NumericField( "dateArchived", Field.Store.YES,
Field.Index.NOT_ANALYZED ).setLongValue( dateArchived.getTime() ) );

Of course that changes the precision of that field, but will that be
compatible with an index storing those Fields as Strings?  If I change the
format of this field to NumericField will the IndexSearcher be able to read
it?  Or will I have to rebuild the entire index?  Finally, now that there is
the concept of a NumericField do I need to worry about indexing with a lower
precision than milliseconds as I did when in using RangeQuery?  Finally will
queries that are parsed from strings be converted into NumericRangeQuery
when the field is a NumericField?  Or do I have to handle that?

Charlie

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message