Solr - 返回随机结果(按随机排序) [英] Solr - Return random results (Sort by Random)
本文介绍了Solr - 返回随机结果(按随机排序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Solr 中,随机排序结果的最佳方法是什么?,基本上需要随机选择一些记录.
In Solr, Whats the best approach to order results by random?, basically needs to pick some records at random.
推荐答案
使用 RandomSortField.示例目录(solr
下)中捆绑的 schema.xml 中有一个示例:
Use a RandomSortField. There's an example in the bundled schema.xml in example directory (under solr
):
<dynamicField name="random_*" type="random" />
按字段 random_
对结果列表进行排序,您可以在该字段中将
替换为随机生成的值(但如果您需要使用相同的值)重新分页结果,因为它会根据字段名称为您提供稳定的排序).
Sort your result list by the field random_<seed>
, where you replace <seed>
with a randomly generated value (but use the same value if you're paginating through the result, as it will give you a stable sort based on the field name).
这篇关于Solr - 返回随机结果(按随机排序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文