有没有办法在脚本处理器中访问elastic 8.x上的旧_type元数据?

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

使用Elasticsearch 8.8

我尝试使用脚本管道重新索引文档,我会将旧的 _type 元数据转换为新字段“@type”,但所有脚本都会从文档源中删除所有 _type 和 _score 字段。有没有办法获取用于设置新字段的字符串?

主要目标是从 elastic 2.4 到 8 的大型升级

文档示例:

{
  "_index": "foo",
  "_type": "bar",
  "_source": {
  }
}

目标:

{
  "_index": "foo",
  "_source": {
    "@type": "bar"
  }
}

尝试类似的事情:

ctx['@type'] = ctx._type
将返回“null”,因为 _type 在运行任何内容之前已被删除。有解决办法吗?

elasticsearch mapping elastic-stack data-ingestion
1个回答
0
投票

据我所知,这是不可能的,因为在 ES 8 中,reindex context 不再提供该信息。在删除映射类型之前直到 6.8 之前都是这种情况。

您需要做的是首先更新 2.4 源集群中的数据以添加该字段,因为 2.4 提供了

ctx._type
信息,然后才重新索引到 8.9

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