lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ype Kingma <ykin...@xs4all.nl>
Subject Re: Enumerating all documents
Date Sat, 17 Nov 2001 12:35:58 GMT
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>


Mime
View raw message