-1

I want a list of all the (path of the) documents contained in a given Lucene 4 index.

According to this, (see item Lucene-2600) the code to use is

import org.apache.lucene.util.Bits; 
import org.apache.lucene.index.MultiFields;

Bits liveDocs = MultiFields.getLiveDocs(indexReader);
if (!liveDocs.get(docID)) {
// document is deleted...
}

But, the getLiveDocs documentation states liveDocs can be null.

What happens in that case? Is there really no easy way to list the documents in a index?

Related post

Community
  • 1
  • 1
meto
  • 3,425
  • 10
  • 37
  • 49

1 Answers1

0

Why not simply:

int maxDoc = indexReader.maxDoc();
for (int doc=0; i<maxDoc; i++)
{
     Document d = indexReader.doc(doc);
     ...
}
Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121