lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From VIGNESH S <vigneshkln...@gmail.com>
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
1.Filename
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
IndexWriterConfig(Version.LUCENE_36,analyzer));
						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
<lucene@mikemccandless.com> 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
>
> http://blog.mikemccandless.com
>
> On Thu, Jan 31, 2013 at 6:43 AM, VIGNESH S <vigneshklncit@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-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>



-- 
Thanks and Regards
Vignesh Srinivasan
9739135640

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message