Solr - How to boost score for early matches?

旧城冷巷雨未停 提交于 2019-12-29 06:55:42

问题


How can I boost the score for documents in which my query matches a particular field earlier. For example, searching for "super man" should give "super man returns" a higher score than "there is my super man". Is this possible?


回答1:


Check for options @ Ranking-based-on-term-position




回答2:


Solved it myself after reading a LOT about this online. What specifically helped me was a reply on nabble which goes like (I used dismax, so explaining that here):

  • Create a separate field named say 'nameString' which stores the value as "_START_ <actual data>"
  • Change the search query to "_START_ <actual query>"
  • Add the new field nameString as one of the fields to look in in the query fields param (qf)
  • While searching use the parameter pf (phrase field) as the new field nameString with a phrase slop of 1 or 2 (lower values would mean stricter searching)

Your final query params will be something like:

q=_START_ <actual query>
defType=dismax
qf=name nameString /* look in name field as well as nameString field */
pf=nameString /* phrase field in nameString */
ps=2 /* phrase slop */


来源:https://stackoverflow.com/questions/12070016/solr-how-to-boost-score-for-early-matches

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