lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris D <>
Subject Adding document with FileReader and deletions.
Date Tue, 07 Jun 2005 18:59:29 GMT
Hi list,

I've been trying to use lucene to index documents that change
occasionally with fields that change frequently. When I add the
contents of the file they are removed when I try to delete and readd
the document. I and am using something like the following.

public void index(String stuff, File f, boolean doContents){
   Document doc = new Document();
   reader =;
   TermDocs td = reader.termDocs(new Term("fileid", fileid));
   //Load the document into memory and delete the document from the index.
      doc = reader.document(tc.doc());
      reader.delect(new Term("fileid", fileid)); //*******
   //We're done deleting so we can move along.
   writer = new IndexWriter(...);

   doc.add(new Field("stuff", stuff, File.Store.YES, File.Index.TOKENIZED));
   //More fields...

   //If the contents need to be readded... Do so.
      doc.add(new Field("contents", new FileReader(f), Field.TermVector.YES));

There are other fields in doc that will stay the same when it updates
which is why I do the removeFields instead of just deleting the doc
and replacing it.

Now if I remove the reader.delete call that's starred the contents get
added. (Albeit over and over again) If it remains then all of the
contents go missing in the index. (Verified with Luke and by searching
for contents:a* etc)

I figure I'm missing something silly, hopefully someone can help me
out, I've been fighting with this for a day or two now, with little
progress, but many more printlns.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message