更新多字段完成建议权重

Update Multi-field Completion Suggester Weighting

给定以下映射:

{
  "index-name-a" : {
    "mappings" : {
      "properties" : {
        "id" : {
          "type" : "integer"
        },
        "title" : {
          "type" : "keyword",
          "fields" : {
            "suggest" : {
              "type" : "completion",
              "analyzer" : "standard",
              "preserve_separators" : true,
              "preserve_position_increments" : true,
              "max_input_length" : 50
            }
          }
        }
      }
    }
  }
}

如何更新单个文档的权重?我尝试了以下方法:

PUT /index-name-a/_doc/1
{
  "title.suggest" : {
    "weight" : 30
  }
}

哪些错误:

Could not dynamically add mapping for field [title.suggest]. Existing mapping for [title] must be of type object but found [keyword]

这是有道理的,因为 属性 是关键字类型而不是对象。但是我找不到正确的方法。我能找到的最近的 in the docs 如果它是一个多字段似乎不起作用。

解决方法

事实上,我可以在 elasticsearch v 8.1

上重现此行为
PUT /72342475-2/
{
  "mappings": {
    "properties": {
      "id": {
        "type": "integer"
      },
      "title": {
        "type": "completion",
        "analyzer": "standard",
        "preserve_separators": true,
        "preserve_position_increments": true,
        "max_input_length": 50,
        "fields": {
          "suggest": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

PUT 72342475-2/_doc/1?refresh
{
  "title": ["nevermind", "smell like teen spirit"],
  "title.weight": 22
}