问题描述
我面临基于用户点击日志排序Lucene结果的问题。我想要更多的访问结果首先。有没有人知道如何在Lucene或Solr中配置或实现这样的属性?
非常感谢。
您可以在架构中声明一个可排序的整数字段(我们称之为clickNum),默认情况下为每个索引文档将其设置为零。
当用户打开文档时,您的应用通过设置clickNum = clickNum + 1触发clickNum字段的更新。
在查询侧,您可以设置一个muptiple基于您的主要排序参数(如果有)进行排序和clickNum:
sort =< field name> +< direction> [,clickNum + desc]
/ p>
您可以通过将点击日志存储在外部数据库中并通过查询后处理重新排序结果,避免文档更新,但是IMHO不是一个好选择。
I am facing the problem of sort Lucene results based on user click log. I would like that more accessed results comes first. Does anyone knows how to configure or implement such property in Lucene or Solr?
Thank you very much.
You can declare a sortable integer field (let's call it clickNum) in your schema, setting it to zero by default for each indexed document.When a user opens a document your app triggers an update of clickNum field by setting clickNum = clickNum + 1.
At query-side you can set a muptiple sorting based on your primary sort parameter (if any) and clickNum:sort=<field name>+<direction>[,clickNum+desc]
You can avoid document update by storing your click log in an external database and reordering your results with post-query elaboration, but IMHO that's not a good option.
这篇关于Solr / Lucene用户点击排名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!