views:

165

answers:

2

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.

A: 

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
A: 

Using Dismax could be a good option. The bf (Boost Functions) parameter of Dixmax 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.

Pascal Dimassimo