lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Wettin <karl.wet...@gmail.com>
Subject Re: getting a random doc from index
Date Fri, 29 Aug 2008 13:31:05 GMT

29 aug 2008 kl. 15.21 skrev Cam Bazz:

> hello,
>
> how could I possibly get a select a random document out of a document
> collection inside a lucene index?


Something like

public Document randomDoc() {
   int docNo = (int)(new java.util.Random().nextDouble() *  
indexReader.maxDoc());
   return indexReader.isDeleted(docNo) ? randomDoc() :  
indexReader.doc(docNo);
}

?



---------------------------------------------------------------------
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