【问题标题】:Elastic search update mappings弹性搜索更新映射
【发布时间】:2020-11-24 10:13:25
【问题描述】:

我在弹性搜索中为对象创建了错误的映射。有没有办法更新映射。为对象类型(字符串而不是双精度)创建了错误的映射。

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    一般来说,现有字段的映射无法更新。这条规则有一些例外。例如:

    new properties can be added to Object datatype fields.
    new multi-fields can be added to existing fields.
    doc_values can be disabled, but not enabled.
    the ignore_above parameter can be updated.
    

    来源:https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

    【讨论】:

      【解决方案2】:

      这完全有可能,通过PUTting 新映射覆盖现有的here are some examples

      请注意,完成此操作后,您可能需要重新索引所有数据,因为我认为 ES 不能将字符串索引转换为双索引。 (取而代之的是,当您在该字段中搜索时,您将找不到任何文档)

      【讨论】:

        【解决方案3】:

        PUT Mapping API 允许您在现有索引中添加/修改数据类型。

        PUT /assets/asset/_mapping
        {  
          "properties": {
            "common_attributes.asset_id": {
              "type": "text",
              "fields": {
                "keyword": { 
                  "type":  "keyword",
                  "doc_values": true,
                  "normalizer": "lowercase_normalizer"
                }
              }
            },
          }
        }
        

        更新映射后,使用批量更新 API 更新现有文档。

        POST /_bulk
        {"update":{"_id":"59519","_type":"asset","_index":"assets"}}
        {"doc":{"facility_id":491},"detect_noop":false}
        

        注意 - 使用 'detect_noop' 来检测 noop 更新。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-08-26
          • 1970-01-01
          • 1970-01-01
          • 2016-06-20
          • 1970-01-01
          相关资源
          最近更新 更多