title: Lucene 2.9.2: How to show results in random order?
body: <p>By default, Lucene returns the query results in the order of relevance (score).
  You can pass a sort field (or multiple), then the results get sorted by that field.</p>
  
  <p>I am looking now for a nice solution to get the search results in <strong>random order</strong>. </p>
  
  <p><em>The bad approach:</em><br>
  Of course I could take ALL results and then shuffle the collection, but in case of 5 Mio search results, that's not performing well.</p>
  
  <p><em>The elegant paged approach:</em><br>
  With this approach you would be able to tell Lucene the following:<br>
  a) Give me results 1 to 10 out of 5Mio results in random order<br>
  b) Then give me 11 to 20 (based on the same random sequence used in a).<br>
  c) Just to clarify: If you call a) twice you get the same random elements.  </p>
  
  <p>How can you implement this approach??</p>
  
  <hr>
  
  <p>Update Jul27 2012: Be aware that the solution described <a href="https://stackoverflow.com/a/7202657/356815">here</a> for Lucene 2.9.x is not working properly. Using the <code>RandomOrderScoreDocComparator</code> will result in having certain results <strong>twice</strong> in the resulting list.</p>