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 Dragon Fly <dr...@hotmail.com> on 2008/11/03 13:51:03 UTC

RE: Read all the data from an index

Thank you both for your help.

> Date: Fri, 31 Oct 2008 09:06:50 +0100
> From: ab@getopt.org
> To: java-user@lucene.apache.org
> Subject: Re: Read all the data from an index
> 
> 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: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 

_________________________________________________________________
Want to read Hotmail messages in Outlook? The Wordsmiths show you how.
http://windowslive.com/connect/post/wedowindowslive.spaces.live.com-Blog-cns!20EE04FBC541789!167.entry?ocid=TXT_TAGLM_WL_hotmail_092008