directory = new SimpleFSDirectory( indexLocation ); IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_47, new WhitespaceAnalyzer( Version.LUCENE_47 )); indexWriter = new IndexWriter( directory, config ); Document doc = new Document(); String value = "hello"; String key = "test"; doc.add( new StringField( key, value, Store.YES ) ); indexWriter.updateDocument( new Term( key, value ), doc ); // (*) indexWriter.commit(); indexWriter.updateDocument( new Term( key, value ), doc ); indexWriter.commit(); indexWriter.close(); reader = DirectoryReader.open( directory ); Assert.assertEquals( 1, reader.maxDoc() );// fails unless (*) is uncommented
-----Ursprüngliche Nachricht----- Von: Michael McCandless [mailto:luc...@mikemccandless.com] Gesendet: Mittwoch, 18. Juni 2014 16:20 An: Lucene Users Betreff: Re: IndexWriter#updateDocument(Term, Document) Your first case is supposed to work; if it doesn't it's a bad bug :) Can you reduce it to a small example? Mike McCandless http://blog.mikemccandless.com On Wed, Jun 18, 2014 at 10:08 AM, Clemens Wyss DEV <clemens...@mysign.ch> wrote: > I would like to perform a batch update on an index. In order to omit > duplicate entries I am making use of IndexWriter#updateDocument(Term, > Document) > > open an IndexWriter; > foreach( element in elementsToBeUpdatedWhichHaveDuplicates ) { doc = > element.toDoc(); indexWriter.updateDocument( uniqueTermForElement, doc > ); } > > Unfortunately this does not seem to work, whereas > > open an IndexWriter; > foreach( element in elementsToBeUpdatedWhichHaveDuplicates ) { doc = > element.toDoc(); indexWriter.updateDocument( uniqueTermForElement, doc > ); indexWriter.commit(); // expensive? > } > > does. How can I batchupdate without commiting? > > --------------------------------------------------------------------- > 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