Get 50 random rows from Sphinx query

徘徊边缘 提交于 2019-12-08 12:50:53

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!