簡體   English   中英

Elasticsearch 如何在重新索引時刪除字段

[英]Elasticsearch how to remove a field while reindexing

我正在嘗試刪除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 index(2020.11.05.02) 有索引模板

    {
      "review_meta" : {
        "match" : "review_meta",
        "mapping" : {
          "type" : "object"
        }
      }
    }

您的腳本應該是這樣的,然后它將起作用:

ctx._source.data.properties.remove('review_meta')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM