: I think you could implement your own scoring algorithm to provide a
: random score to each document in the result set
: (http://lucene.apache.org/java/docs/api/org/apache/lucene/search/package
: -summary.html#changingSimilarity). The default sort would then operate
: on the random values.

I'd be really suprised if you could get a "fair" random distribution with
a custom similarity.  You could write a custom ValueSource thta builds a
"FieldCache" like structure where the values are random and then use that
in a FunctionQuery -- but using that in combination with another query to
restrict the result set would be ... anoying.

the cleanest approach to truely randomize the order of any search
at the "Lucene" level would be with a new
SortComparatorSource/ScoreDocComparator ... but if you were willing
to put custom logic in at the "Solr" level you could do this in the
a RequestHandler using a DocIterator ... there's an algorithm for
fairly picking N random elements from a stream of elements even when you
don't know the length of the stream, i don't remember what it's called but
i could probably remember the psuedo code if no one else knows what i'm
talking about (i believe it involves maintaining a queue of size N and
pushing item number I onto the queue if a random float F < 1/I)



-Hoss

Reply via email to