how do I normalise a solr/lucene score?

前端 未结 3 1630
自闭症患者
自闭症患者 2020-12-01 06:51

I am trying to work out how to improve the scoring of solr search results. My application needs to take the score from the solr results and display a number of “stars” depe

3条回答
  •  悲&欢浪女
    2020-12-01 07:25

    I've never had to do anything this complicated in Solr, so there may be a way to hook this in as a plugin - but you could handle it in the client when a result set is returned. If you've sorted by relevance this should be staightforward - get the relevence of the first result (max), and the last (min). Then for each result with relevance x, you can calculate

    normalisedValue = (x - min) / (max - min)
    

    which will give you a value between 0 and 1. Multiply by 5 and round to get the number of stars.

提交回复
热议问题