lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: How to properly use updatedocument in lucene.
Date Fri, 01 Feb 2013 06:11:53 GMT
Hi Mike,

Thanks for your reply..

MY Scenario is I am creating Lucene Index with Two Fields
2.File Contents

For Example I initially added fields FileName:-say LuceneInAction.pdf
which is not analysed  FileContents:Content of the Book it is analysed
using custom analyzer.

Now what is the right way to change the only Filename Field to some
other name say LuceneReference.pdf..

As for what i understand,only way to get the DocumentId of a term is
using Search Method..

I get the new file name from the user..and  used Search Method to get
the Doc id and used the updateDocument method to update it with a new
name (LuceneReference.pdf.)..

                                           IndexWriter writer = new
IndexWriter(csDirectory, new
						writer.updateDocument(new Term(NAME_FIELD, "LuceneReference.docx")
It is not updating the index..

is there a way to update index without reindexing the entire document?

Thanks and Regards
Vignesh Srinivasan

On Thu, Jan 31, 2013 at 5:35 PM, Michael McCandless
<> wrote:
> 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
> 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:

Thanks and Regards
Vignesh Srinivasan

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

View raw message