This is exactly the purpose of the IndexWrite#updateDocument method. The first argument is the term that must be unique in your index.
For example,
String id = "42"; Document doc = new Document(); Field field = new Field("id", id, Store.YES, Index.NOT_ANALYZED); doc.add(field); indexWriter.updateDocument(new Term("id", id), doc); will ensure that doc is the only document with id 42 in your index.
Read full article from uniqueidentifier - How to set a field to keep a row unique in lucene? - Stack Overflow
No comments:
Post a Comment