title: Is there a way to randomize search results (record ids) with Sphinx?
body: <p>I have a complex SphinxQL query which, at the end, orders results by a specific field, <code>Preferred</code>, so that all records with that indexed value of Preferred=1 come before all records w Preferred=0. I also order by weight() so basically I end up with:</p>
  
  <p><code>Select * from idx_X where MATCH('various parameters') ORDER by Preferred DESC,Weight() Desc</code></p>
  
  <p>The problem is that, though Preferred records come first I end up with records sorted by ID which puts results from one field, Vendor, in blocks so for instance I get:</p>
  
  <p><code>
  Beta Shipping
  Beta Shipping
  Beta Shipping
  Acme Widgets
  Acme Widgets
  Acme Widgets
  Acme Widgets
  Acme Widgets</code></p>
  
  <p>Which doesn't serve my purposes in this case well (often one 'Vendor' will have 1000 results)</p>
  
  <p>So I'm looking to essentially do:</p>
  
  <p><code>ORDER BY Preferred DESC,weight() DESC,ID RANDOM</code></p>
  
  <p>So that after getting to Preferred Vendors whose weight is (e.g.) <code>100</code>, I will get random Vendors vs blocks of them.</p>
  
  <p><strong>Update</strong>: Though I did find what appears to be a possible answer in another <a href="https://stackoverflow.com/questions/22011194/get-50-random-rows-from-sphinx-query">Stackoveflow Question</a></p>
  
  <p>The issue is it seems to require the <code>SPH_SORT_EXTENDED</code> and I am forced to use <code>SPH_RANK_PROXIMITY</code> (ranker=proximity) and I am unclear if I can combine ranking and sorting.</p>
  
  <p>Update 2: If I remove my existing two-level Order and just do <code>Order by Rand()</code> it indeed returns random IDs. However I cannot add <code>Rand()</code> after <code>Order by Preferred DESC,Weight() DESC</code> or I get the following error:</p>
  
  <p><code>1064 - sphinxql: syntax error, unexpected '(', expecting $end near '()</code></p>