如何在 Elastic 中对现有字段进行空值映射

问题描述 投票:0回答:1

我之前创建了一个索引,我想在其上添加空值属性:

PUT /check_test-1/_mapping
{  "properties": {
    "name": {
      "type": "keyword",
      "null_value":"N/A"
    }}}

现有指数:

{ "check_test-1" : {
"mappings" : {
  "properties" : {
    "name" : {
      "type" : "keyword"
    },
    "status_code" : {
      "type" : "keyword",
      "null_value" : "N/A"
    }
  }
}}}

当我运行上面的查询时,它给出了这个错误:

 "type" : "illegal_argument_exception",
    "reason" : "Mapper for [name] conflicts with existing mapper:\n\tCannot update parameter [null_value] from [null] to [N/A]"

使用以下查询创建索引:

PUT /check_test-1/
{
  "mappings": {
    "properties": {
      "name": {
        "type": "keyword"
      },
      "status_code": {
        "type": "keyword",
        "null_value": "N/A"
      }
    }
  }
}

弹性版本7.10.0

elasticsearch
1个回答
1
投票

就像消息所说,您无法更改字段的现有映射。

查看 Elasticsearch 文档,了解映射更新,尤其是

如果您需要更改其他索引中字段的映射,请使用正确的映射创建一个新索引,并将数据重新索引到该索引中。

© www.soinside.com 2019 - 2024. All rights reserved.