You could implement a HitCollector based around a List of capacity N, and in the Collect method, if the List is full, you decide randomly whether to pop one off the stack and push your new one in the top.
I don't know how truly random you need to be since with this method items you collect last will stand a higher chance of being in the final list. So the less randomly ordered collection is, the less randomly ordered your result will be. Probably Franklin's way is better. M. ------------------------------------- Moray McConnachie Director of IT +44 1865 261 600 Oxford Analytica http://www.oxan.com -----Original Message----- From: Franklin Simmons [mailto:[email protected]] Sent: 25 January 2010 16:32 To: [email protected] Subject: RE: What would be the best way to get a random ordered result? Try implementing SortComparatorSource and ScoreDocComparator and randomize the result of the ScoreDocComparator.Compare method. -----Original Message----- From: Markus Wolters [mailto:[email protected]] Sent: Monday, January 25, 2010 11:08 AM To: [email protected] Subject: What would be the best way to get a random ordered result? Hi, I have one case, where I need a limited resultset in random sort order. What would be the (best) way to achieve that? Markus
