Elasticsearch 如何在重新索引时删除字段

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

我正在尝试删除

data.properties.review_meta
字段,因为它造成了麻烦

POST /_reindex
{
  "source": {
    "index": "analytics-prod-2020.11.05"
  },
  "dest": {
    "index": "analytics-prod-2020.11.05.02"
  },

  "conflicts": "proceed",

  "script" : {
    "source": "ctx._source.data.remove('properties.review_meta')"
  }

}

代码不适用于错误消息

 "failures" : [
    {
      "index" : "analytics-prod-2020.11.05.02",
      "type" : "_doc",
      "id" : "gksugnUBaMafnb1n2Iqy",
      "cause" : {
        "type" : "mapper_parsing_exception",
        "reason" : "object mapping for [data.properties.review_meta] tried to parse field [review_meta] as object, but found a concrete value"
      },
      "status" : 400
    },
    {
      "index" : "analytics-prod-2020.11.05.02",
      "type" : "_doc",
      "id" : "jUsvgnUBaMafnb1nsrkC",
      "cause" : {
        "type" : "mapper_parsing_exception",
        "reason" : "object mapping for [data.properties.review_meta] tried to parse field [review_meta] as object, but found a concrete value"
      },
      "status" : 400
    }
  ]

来源索引(2020.11.05)有

            "review_meta" : {
              "type" : "long"
            },

dest索引(2020.11.05.02)有索引模板

    {
      "review_meta" : {
        "match" : "review_meta",
        "mapping" : {
          "type" : "object"
        }
      }
    }
elasticsearch
1个回答
0
投票

你的脚本应该像这样,然后它就会起作用:

ctx._source.data.properties.remove('review_meta')
© www.soinside.com 2019 - 2024. All rights reserved.