Erick Erickson wrote:
I'm not sure what *could* be easier than looping with IndexSearcher.doc(),
looping from 1 to maxDoc. Of course you'll have to pay some attention to
whether you get a document back or not, and I'm not quite sure whether you'd
have to worry about getting deleted documents. But I don't think either of
these
really count if the index was optimized

Document numbers start at 0. You will never get a document marked "deleted" from either IndexReader or IndexSearcher.

Why use IndexSearcher and not IndexReader?

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().

--
Best regards,
Andrzej Bialecki     <><
 ___. ___ ___ ___ _ _   __________________________________
[__ || __|__/|__||\/|  Information Retrieval, Semantic Web
___|||__||  \|  ||  |  Embedded Unix, System Integration
http://www.sigram.com  Contact: info at sigram dot com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to