Rob Outar wrote:
public synchronized String[] getDocuments() throws IOException {

        IndexReader reader = null;
        try {
            reader = IndexReader.open(this.indexLocation);
            int numOfDocs      = reader.numDocs();
            String[] docs      = new String[numOfDocs];
            Document doc       = null;

            for (int i = 0; i < numOfDocs; i++) {
                doc = reader.document(i);
                docs[i] = doc.get(SearchEngineConstants.REPOSITORY_PATH);
            }
            return docs;
        }
        finally {
            if (reader != null) {
                reader.close();
            }
        }
    }

The limit of your iteration should be IndexReader.maxDoc(), not IndexReader.numDocs():


http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/IndexReader.html#maxDoc()

Also, you should first check that each document is not deleted before calling IndexReader.document(int):

http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/IndexReader.html#isDeleted(int)

Doug


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



Reply via email to