You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Paul Cunningham <pj...@borsuk.uk.net> on 2001/11/17 12:15:00 UTC

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Enumerating all documents

Posted by Paul Cunningham <pj...@borsuk.uk.net>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Enumerating all documents

Posted by Ype Kingma <yk...@xs4all.nl>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>