推动Elasticsearch [英] Boosting in Elasticsearch

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

问题描述

我是Elasticsearch的新手。在Elasticsearch中,我们几乎可以在所有查询中使用术语boost。我了解它用于修改文档分数。但我找不到它的实际用途。我的疑问是,如果我在某些查询中使用提升值,会影响最终的搜索得分或文档本身在索引中的提升等级。

I am new to elasticsearch. In elasticsearch we can use the term boost in almost all queries. I understand it's used for modify score of documents. But i can't find actual use of it. My doubt is if i use boost values in some queries, will it affect final score of search or the boost rank of docs in index itself.

索引的提升和查询的提升之间的主要区别是什么。

And what is main difference between boost at index and boost at querying..

谢谢。 !

推荐答案

查询时间提升使您可以给一个查询更多的权重。例如,假设您要查询 Quick Brown Fox的 title body 字段,则可以编写它如:

Query time boost allows you to give more weight to one query than to another. For instance, let's say you are querying the title and body fields for "Quick Brown Fox", you could write it as:

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": "Quick Brown Fox"
          }
        },
        {
          "match": {
            "body": "Quick Brown Fox"
          }
        }
      ]
    }
  }
}

但是您决定要使用 title 字段比 body 字段更重要,这意味着您需要 boost title 字段,例如:2:

But you decide that you want the title field to be more important than the body field, which means you need to boost the query on the title field by (eg) 2:

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": {
              "query": "Quick Brown Fox",
              "boost": 2
            }
          }
        },
        {
          "match": {
            "body": "Quick Brown Fox"
          }
        }
      ]
    }
  }
}

(请注意 match 子句的结构已更改,以适应 boost 参数)。

(Note how the structure of the match clause changed to accommodate the boost parameter).

2 boost 值不会使 _score boost 使此查询子句比其他查询子句相对更重要

The boost value of 2 doesn't double the _score exactly - the scores go through a normalization process. So you should think of boost as make this query clause relatively more important than the other query clauses.


我的疑问是我是否在某些查询中使用boost值。它会影响搜索的最终得分吗?

My doubt is if i use boost values in some queries. will it affect final score of search

是的,但是您不应该依赖 _score 。其唯一目的是允许Elasticsearch确定与该查询最相关的文档。如果查询更改,则分数也会更改。

Yes it does, but you shouldn't rely on the actual value of _score anyway. Its only purpose is to allow Elasticsearch to decide which documents are most relevant to this query. If the query changes, the scores change.

重新索引时间增加:请勿使用。它不灵活且容易出错。

Re index time boosting: don't use it. It's inflexible and error prone.

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

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