lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Attardi" <jatta...@gmail.com>
Subject IndexWriter.updateDocument(Term, Document) not removing old Document?
Date Tue, 03 Jul 2007 17:51:56 GMT
Hi everybody,

First-time poster here. I've got a search index that I am using to index
live Java objects. I create a Document with the appropriate fields and index
them. No problem. I am indexing objects of different types, so I have an
"id" field in each Document which consists of the object's class name
followed by a unique ID number, so for example
"com.mycompany.myapp.FooBar142". When the objects get updated, I make
a new Document and call
IndexWriter.updateDocument as follows:

IndexWriter indexWriter = new IndexWriter(INDEX_PATH, new
StandardAnalyzer(), false);
Document doc = buildDocumentFor(object);
Term term = new Term("id", "\"" + doc.get("id") + "\"");
indexWriter.updateDocument(term, doc);
indexWriter.close();

The call to update() goes off without any problems, and the new Document
gets added to the index. But when checking the index, I find that the old
Document still exists.

Am I missing something? The Javadoc for updateDocument states "Updates a
document by first deleting the document(s) containing term and then adding
the new document. The delete and then add are atomic as seen by a reader on
the same index (flush may happen only after the add)."

Thanks for your help..

-- 
Joe Attardi
jattardi@gmail.com
http://thinksincode.blogspot.com/

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