lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: How to properly use updatedocument in lucene.
Date Thu, 31 Jan 2013 12:05:15 GMT
It's confusing, but you should never try to re-index a document you
retrieved from a searcher, because certain index-time details (eg,
whether a field was tokenized) are not preserved in the stored

Instead, you should re-build the document yourself, setting the right
details per-Field, and then re-index that.

Separately, that's the right way to call .updateDocument, but you must
ensure FILE_NAME_FIELD was indexed for the first document, with the
value "new1.docx".

Can you include how you indexed the original document?

Mike McCandless

On Thu, Jan 31, 2013 at 6:43 AM, VIGNESH S <> wrote:
> Hi All,
> I am having a basic doubt..
> I am trying to update a lucene document field with a new value..
> The below is my code.. It is not giving any errors and also it is not
> updating the document with field.
> Document d = searcher.doc(docId);
> writer1 = new IndexWriter(csDirectory, new
> IndexWriterConfig(Version.LUCENE_36,analyzer));
>  writer1.updateDocument(new Term(FILE_NAME_FIELD,"new1.docx"),d);
> Please help me in this..
> Also Suggest me if there is a better way to updateDocument without
> using search()..
> --
> Thanks and Regards
> Vignesh Srinivasan
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message