lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: How to add DocValues Field to a document in an optimal manner.
Date Thu, 01 Mar 2012 14:25:08 GMT
You shouldn't use doc.removeField -- it's costly (the fields are a
list internally so we walk that list looking for which field(s) to

To reuse you can just use Field.setValue, and leave the Field instance
on the Document.

But: you should only do this if you really have a meaningful
performance problem during indexing...

Mike McCandless

On Thu, Mar 1, 2012 at 2:20 AM, 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);
> If this is the pattern that users should follow while creating
> documents, would it be possible to augment the Document class to do
> this in a single method?
> regards
> Sudarshan
> --
> Sudarshan Gaikaiwari
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message