1

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.

Danim
  • 11
  • 2

2 Answers2

2

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.

mamoo
  • 8,156
  • 2
  • 28
  • 38
0

Using Dismax could be a good option. The bf (Boost Functions) parameter of Dismax could be set to boost the documents with a high click count.

If you don't want to use Dismax, you can also use a function query in the bf (Boost Functions) parameter.

javanna
  • 59,145
  • 14
  • 144
  • 125
Pascal Dimassimo
  • 6,908
  • 1
  • 37
  • 34