Elasticsearch: Filter out irrelevant results based on score

血红的双手。 提交于 2021-01-28 05:06:36

问题


When I run a query I get back results with their relevance scores. For example consider the following records in the results with their scores,

  • record 1 : score = 11.5
  • record 2 : score = 11.2
  • record 3 : score = 10.6
  • record 4 : score = 9.9
  • record 5 : score = 2.1
  • record 6 : score = 1.9

I want the records 5 and 6 to be filtered out as you can see they are the irrelevant subset of results. Difference of score between record 3 & 4 is less as compared to the difference between 5 & 4

Is there a way in elasticsearch to filter out the irrelevant results. To use the min_score query you should know the scores before hand hence that will not be a solution


回答1:


ES is using Lucene under the covers for the scoring, and you cannot know beforehand what range of scores you will get from a query. You could use some function score to normalize scores etc, but it would be very difficult not to find some cases where it would perform badly. It is not recommended.

If you need to know how Lucene calculates the scores, google for BM25.



来源:https://stackoverflow.com/questions/43922588/elasticsearch-filter-out-irrelevant-results-based-on-score

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