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 document.
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 http://blog.mikemccandless.com On Thu, Jan 31, 2013 at 6:43 AM, VIGNESH S <vigneshkln...@gmail.com> 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: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org