Mailing List Archive

Enumerating all documents
Hello,

Is it possible to enumerate ALL the documents in a Lucene index, say for
house-keeping purposes.

Thanks in advance,

Paul Cunningham

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Enumerating all documents [ In reply to ]
Paul,

>Hello,
>
>Is it possible to enumerate ALL the documents in a Lucene index, say for
>house-keeping purposes.

Off the top of my head:

for (int docNr = 0; docNr < indexReader.maxDoc(); docNr++) {
if (! indexReader.isDeleted(docNr)) {
Document enumeratedDoc = indexReader.document(docNr);
...
}
}

>Thanks in advance,

My pleasure. It might work, but I may have misspelled something,
and my builtin Java syntax checker has not been used for quite
some time. I'm currently playing with Lucene from jython:

for docNr in range(indexReader.maxDoc()):
if not indexReader.isDeleted(docNr):
enumeratedDoc = indexReader.document(docNr)
...

Have fun,
Ype

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Enumerating all documents [ In reply to ]
Hello Ype,

Great, that works fine. I should have been able to work it out myself, but
I hadn't spotted the static open methods of the IndexReader class. After
looking at your code I read the API more carefully.

Cheers,

Paul Cunningham.

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>