lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toke Eskildsen ...@statsbiblioteket.dk>
Subject Re: TopDocs - Get all docs?
Date Wed, 17 Dec 2008 13:16:31 GMT
On Mon, 2008-12-08 at 15:17 +0100, Donna L Gresh wrote:
>         public Vector getIndexIds() throws Exception {
>  
>                 Vector vec = new Vector();
>                 IndexReader ireader = IndexReader.open(directoryName);
>                 int numdocs = ireader.numDocs();
>                 for (int i=0; i<numdocs; i++) {
>                         Document doc = ireader.document(i);

It's probably best to perform a check for ireader.isDeleted(i) here,
unless the index never contains deleted documents.

>                         Field field = doc.getField("empid");
>                         if (field==null) {
>                                 continue;
>                         }
>                         String contents = field.stringValue();
>                         vec.add(contents);
>                 }
>                 return vec;
>         }


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


Mime
View raw message