lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trejkaz <>
Subject Re: How to add DocValues Field to a document in an optimal manner.
Date Thu, 01 Mar 2012 07:34:00 GMT
On Thu, Mar 1, 2012 at 6:20 PM, Sudarshan Gaikaiwari <> wrote:
> Hi
> The documentation at the above link indicates that the optimal way to
> add a DocValues field is to create it once and change the value as we
> are indexing multiple documents.
> It also mentions that the Document should be created only once and re-used.
> Does this mean that the optimal way of adding non DocValues fields for now is
> doc.removeField(fieldName);
> doc.add(new Field(fieldName, newValue, fieldType);

I'm pretty sure you're supposed to reuse *all* Field instances, for
optimum performance.

Though admittedly this is quite tricky to do right if you have
multiple fields with the same name in the document where the number of
fields might change for each document you add.

If you only have one of each, just add all the fields to the document
once and keep a reference to them, then just set the value on each
before doing your addDocument.


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

View raw message