问题
I have a PHP website using Sphinx by sphinxClient lib.
My Sphinx query has some filters and a limit of 2500 rows. From the 2500 rows (could be less), I want to fetch just 50 random rows.
Is there a way to do it using only Sphinx?
Edit: The original query already sorted by the popularity of the rows, the main idea is to get 50 random products from the 2500 most popular. Because of that I can't sort by random
回答1:
See SPH_SORT_EXTENDED
. There is a @random
sort order
http://sphinxsearch.com/docs/current.html#sorting-modes
回答2:
What's the issue with using order by RAND() limit 50
Check this link for similar result. sphinxQL fetching random?
来源:https://stackoverflow.com/questions/22011194/get-50-random-rows-from-sphinx-query