lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)" <nageshbl...@gmail.com>
Subject Deleted documents in the index.
Date Fri, 25 Jul 2008 11:17:55 GMT
Hi,
I am writing a class to report on an index. This index has documents updated
using the IndexWriter.updateDocument(Term, Document) method. That is,
documents were deleted and added again. My aim is to see what documents (and
their fields) are present in the index. Since the document was updated (i.e.
deleted and added), it is marked as deleted and hence not able to obtain a
Document object for the updated document.

How do I report on such documents ?

for (int i = 1; i < numDocs; i++) {
//ir is an IndexReader object
            if (ir.isDeleted(i)) {
                bw.write("Document " + i + " has been deleted.");
                bw.newLine();
            } else {
                Document d = getDocument(ir, i);

                List<Field> l = d.getFields();
                int numFields = l.size();
                bw.write("Document has " + numFields + " fields as
follows");
                bw.newLine();

                for (int j = 0; j < numFields; j++) {
                    String fieldName = l.get(j).name();
                    bw.write("\t Field : " + fieldName + " Value : "
                            + d.getField(fieldName).stringValue());
                    bw.newLine();
                }
            }
        }

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