ElasticSearch中的分类评分 [英] Clasterized scoring in ElasticSearch

查看:173
本文介绍了ElasticSearch中的分类评分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在ElasticSearch 6.2中得到了一些复杂的查询,它可以返回下一个匹配:

Let's say I got some complex query in ElasticSearch 6.2 and it can return the next hits:

"hits" : [
  {
    ...
    "_score" : 100,
    "_source" : { ... }
    ...
  },
  {
    ...
    "_score" : 99,
    "_source" : { ... }
    ...
  },
  {
    ...
    "_score" : 50,
    "_source" : { ... }
    ...
  },
  {
    ...
    "_score" : 49,
    "_source" : { ... }
    ...
  }
]

或者相同的查询可以返回:

Or the same query can return:

"hits" : [
  {
    ...
    "_score" : 10,
    "_source" : { ... }
    ...
  },
  {
    ...
    "_score" : 9.9,
    "_source" : { ... }
    ...
  },
  {
    ...
    "_score" : 2,
    "_source" : { ... }
    ...
  },
  {
    ...
    "_score" : 1,
    "_source" : { ... }
    ...
  }
]

如您所见,分数分布不均匀,并且有几组分数接近的项目.我需要将结果集包括在顶级组的项目中.我无法提供合理的min_score,因为对于不同的查询参数,绝对得分值可能会相差很大.有什么方法可以使Elastic返回实际得分最高的组,而不管实际的绝对值如何?预先谢谢你.

As you see the distribution of score is uneven and there are group of items with close scores. I need to include to result set on items from top group. I can't provide the reasonable min_score, because for different query parameters the absolute score values can differ very much. Is there any way to make Elastic return the top scored group regardless of actual absolute values? Thank you in advance.

推荐答案

据我所知,Elasticsearch并没有提供一种基于相对分数来减少某些匹配的方法.为了做到这一点,您应该事先知道最大分数,这取决于搜索查询本身和索引的当前状态可能会非常不同.一种不太理想的方法是从第一个请求中获得最大分数,将结果的大小限制一个最大值,然后在第二个请求中使用相对min_score来过滤结果.另一方面,可以通过在客户端手动过滤常规查询的结果来实现相同的目的.

As far as I know Elasticsearch does not provide a way to cut off some hits based on the relative score. In order to do it you should know in advance the maximum score which can be very different depending on the search query itself and on the current state of the index. One not very elegant way to achieve this is to get a maximum score from the first request that limits size of the results by one and then use relative min_score in the second request to filter out the results. On the other hand the same can be achieved by filtering results of the regular query manually on the client side.

这篇关于ElasticSearch中的分类评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆