1. boost(提升)

原文链接 :https://www.elastic.co/guide/en/elasticsearch/reference/5.3/mapping-boost.html

译文链接 : boost(提升)

贡献者 : 程威ApacheCNApache中文网

个别字段可以自动 boost (提升)权重 – 通过相关性分数来进行计数 - 在查询的时候, boost(提升)参数使用如下 :

curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "my_type": {
      "properties": {
        "title": {
          "type": "text",
          "boost": 2  (1)
        },
        "content": {
          "type": "text"
        }
      }
    }
  }
}
'

| 1 | 匹配的 title 字段的权重将两倍于 content 字段,默认的 boost 的值为1.0. |

Note

boost(提升)参数仅适用于 term(词条)查询(前缀,范围和模糊查询不能够使用 boost ).

你可以通过直接在查询中使用 boost(提升)参数来实现相同的效果,例如下面这个查询(使用字段时间 boost(提升))

curl -XPOST 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
    "query": {
        "match" : {
            "title": {
                "query": "quick brown fox"
            }
        }
    }
}
'

等同于

curl -XPOST 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
    "query": {
        "match" : {
            "title": {
                "query": "quick brown fox",
                "boost": 2
            }
        }
    }
}
'

[_all](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/mapping-all-field.html "_all field")字段中的值被复制引用时, boost(提升) 参数也会得到应用.这意味着,当查询 _all 字段的时候,源自 title 字段的单词将具有比源自 content 字段更高的 score(分数). 这就会产生一定的代价 : 当使用字段 boosting(提升时) _all 字段上的查询会变慢.

Deprecated in 5.0.0.

索引的时候 boost(提升) 参数已被弃用.查询的时候 boost(提升)参数在字段映射中是有效的.对于5.0.0之前的版本创建的索引, boost(提升)参数在索引的时候仍然有效.

Why index time boosting is a bad idea

我们建议不要在索引的时候使用 boost(提升)参数,原因如下:

  • 当不需要重新索引所有 documents(文档),在索引的时候,你不能够改变的 boost(提升)参数的值 .
  • 每一个查询都支持 query-time boosting(查询时间的提升)来实现相同的结果.不同之处在于,你可以调整 boost(提升)参数的值而不需要重新索引.
  • Index-time boosts(索引时间的提升)存储为 norm 的一部分,只有一个字节.这降低了字段长度归一化因子的解析度,从而降低质量相关性的计算.
Copyright © Kilvn 2021. all right reserved,powered by Gitbook最后更新时间: 2021-06-08 20:22:42

results matching ""

    No results matching ""