lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Kaser <lucene_l...@iconparc.de>
Subject Re: Newbie Questions
Date Wed, 10 Aug 2016 07:15:14 GMT
There is no way to "update" a document in lucene, you always have to 
remove the existing document and add the updated version with ALL its 
fields. The updateDocument-method of IndexWriter exists only for 
convenience (and to assure the operation is atomic), but internally it 
does just that: remove the old document and add a new one.
In generally, this works best if you get all fields of the document from 
your external datasource instead of the index, because depending on your 
field configuration, there might be some information missing (especially 
for fields that are not STORED or DocValues).

See also the Lucene FAQ:
https://wiki.apache.org/lucene-java/LuceneFAQ#How_do_I_update_a_document_or_a_set_of_documents_that_are_already_indexed.3F

Regards

Am 09.08.2016 um 20:51 schrieb lukes:
> Thanks for the reply.
>
>    Is there a way to partially update the document ? I know there's a API
> updateDocument on IndexWriter, but that seems to create a new document with
> just a field i am specifying. What i want is delete some fields from
> existing(indexed) document, and then add some new fields(could or not be
> same). Alternatively i tried to search for the document, and then calling
> removeFields and finally updateDocument, but now any search after the above
> process is not able for find that document(I created the new IndexReader).
> Am i missing anything ?
>
> Regards.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Newbie-Questions-tp4290817p4291024.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message