lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: Converting Older indexes and NumericField?
Date Fri, 23 Sep 2011 10:15:03 GMT
You'll need to rebuild the whole index.

You may get better performance or save space by using lower precision.
See the javadocs for NumericField.  My advice would be that If you
don't need millisec precision, don't use it.

The release notes for 3.4.0 say "The modular QueryParser
(contrib/queryparser) can now create NumericRangeQuery" so that sounds
well worth a look, if you can upgrade to that release.


On Thu, Sep 22, 2011 at 10:11 PM, Charlie Hubbard
<> wrote:
> 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

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

View raw message