lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arjen van der Meijden <>
Subject Testing whether a document is up-to-date in Lucene 4.0
Date Fri, 12 Oct 2012 14:04:19 GMT
Hello List,

I'm currently trying to update my Lucene 3.6-application to 4.0.

Most of it works (although your migration guide lacks a bit of aspects I 
had to figure out myself), but for one fairly large database I want to 
check whether the Document in the Lucene database is already at the 
latest modification time. If so, I can continue to the next item on the 

So to do that, I index an additional field in the Document with the 
modification time and later retrieve that.

With 3.6, I did this:
IndexReader reader = writer.getReader();
Term idTerm = new Term("idField, "idText");
TermDocs termDocs = reader.termDocs(idTerm);

  int docNum = termDocs.doc();
  Document doc = reader.document(docNum);
  // etc

It worked as far as I can tell, besides, it worked regardless of whether 
the writer was actually started with a empty directory (on disk) or one 
that had data in it.

What is the correct way to implement something like the above procedure 
in 4.0? The writer doesn't have a getReader() anymore and the 
IndexReader doesn't have a termDocs()-method (and the docsEnum is only 
on specific IndexReader's?).

The "migration guide" isn't very clear on this and I wasn't really able 
to find any useful documentation on how the new reader/writer-stuff is 
actually to be used... Did I overlook the documentation?

And there are some additional things to consider, like the database may 
not have been created yet (i.e. it may be empty at the moment of the 
above code). And in my current code, I only have access to the 
IndexWriter, a reader or searcher hasn't even been created yet.

Best regards,


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

View raw message