java-user@lucene.apache.org
[Top] [All Lists]

RE: Read all the data from an index

Subject: RE: Read all the data from an index
From: Dragon Fly
Date: Mon, 3 Nov 2008 07:51:03 -0500
Thank you both for your help.

> Date: Fri, 31 Oct 2008 09:06:50 +0100
> From: ab@xxxxxxxxxx
> To: java-user@xxxxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxxxxxxx
> For additional commands, e-mail: java-user-help@xxxxxxxxxxxxxxxxx
> 

_________________________________________________________________
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
<Prev in Thread] Current Thread [Next in Thread>
  • RE: Read all the data from an index, Dragon Fly <=