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 William Lee <ww...@uiuc.edu> on 2005/02/19 19:10:43 UTC

Iterate through all the document ids in the index?

This should be a very simple question.  But I can't seem to
find the right way to do so.  Anyway, is there a simple and
fast way to get a list of document IDs through the lucene index?  

I can use a loop to iterate from 0 to IndexReader.maxDoc and
check whether an the document id is valid through
IndexReader.document(i), but this would imply that I have to
retrieve the documents fields.

Iterating through from 0 to numDocs would work, I assume, if
the index is optimized (?).  I don't know what would happen if
it's not though.

I also don't think a WildcardQuery would work, since doing a
"*" would give me all the terms and I'd blow over the maximum
term limit in the BooleanQuery.

I'm probably missing something, and I'm sure the experts here
can point me to the obvious.

Thanks,

Will

-- 
William (Will) Lee 
Email: wwlee1@uiuc.edu
Computer Science, University of Illinois at Urbana-Champaign

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


Re: Iterate through all the document ids in the index?

Posted by Doug Cutting <cu...@apache.org>.
William Lee wrote:
> is there a simple and
> fast way to get a list of document IDs through the lucene index?  
> 
> I can use a loop to iterate from 0 to IndexReader.maxDoc and
> check whether an the document id is valid through
> IndexReader.document(i), but this would imply that I have to
> retrieve the documents fields.

Use IndexReader.isDeleted() to check if each id is valid.  This is quite 
fast.

Doug

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