본문 바로가기

Lucene

[lucene] IndexReader를 사용한 모든 Document 읽기.


IndexReader reader = IndexReader.open(....);

for (int i = 0; i < reader.maxDoc(); i++) {
       if (reader.isDeleted(i)) {
               continue;
       }
       Document doc = reader.document(i);
       ...
}

Hint: if you have an unoptimized index with deleted documents, and you want to retrieve also the content of these deleted documents, call first IndexReader.undeleteAll().