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 Cam Bazz <ca...@gmail.com> on 2008/08/29 15:21:35 UTC
getting a random doc from index
hello,
how could I possibly get a select a random document out of a document
collection inside a lucene index?
best regards,
-C.B.
Re: getting a random doc from index
Posted by Karl Wettin <ka...@gmail.com>.
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