Combine solr's document score with a static, indexed score

前提是你 提交于 2019-12-08 10:37:56

问题


I have people indexed into solr based on documents that they have authored. For simplicity's sake, let's say they have three fields - an integer ID, a Text field and a floating point 'SpecialRank' (a value between 0 and 1 to indicate how great the person is). Relevance matching in solr is all done through the Text field. However, I want my final result list to be a combination of relevance to the query as provided by solr and my own SpecialRank. Namely, I need to re-rank the results based on the following formula:

finalScore = (0.8 * solrScore) + (0.2 * SpecialScore)

As far as I'm aware, this is a common task in information retrieval, as we are just combining two different scores in a weighted manner. The trouble is, I need solrScore to be normalized for this to work. What I have been doing is normalizing the solrScore based on the maxScore for a particular query and re-ranking the results client-side. This has been working OK, but means I have to retrieve all the matching documents from solr before I do my re-ranking.

I am looking for the best way to have solr take care of this re-ranking. Are boost functions able to help here? I have read that they can be multiplicative or additive to the solr score, but since the solr score is not normalized and all over the place depending on different queries, this doesn't really seem to solve my problem. Another approach I have tried is to first query solr for a single document just to get the maxScore, and then use the following formula for the sort:

sum(product(0.8,div(score,maxScore)),product(0.2,SpecialRank))+desc

This, of course, doesn't work as you're unable to use the score as a variable in a sort function.

Am I crazy here? Surely this is a common enough task in IR. I've been banging my head against the wall for a while now, any ideas would be much appreciated.


回答1:


You could try to implement custom SearchComponent that will go trough results on Solr and calculate your custom score there. Get results found from ResponseBuilder (rb.getResults().docSet), iterate trough them, add calculated value to your results and re-sort them.

You can then register your SearchComponent as last in RequestHandler chain:

<arr name="last-components">
  <str>elevator</str>
</arr>

More info in SolR manual: http://wiki.apache.org/solr/SearchComponent

Sorry, but no better idea for now.



来源:https://stackoverflow.com/questions/18449810/combine-solrs-document-score-with-a-static-indexed-score

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