elasticsearch - 如何将Elasticsearch数据重新索引到新映射(从平面字段到对象)?

标签 elasticsearch reindex

我有一个旧索引(elasticsearch索引)有超过20K个对象,此索引包含字段

{
    "title": "Test title",
    "title_ar": "عنوان تجريبي",
    "body": "<p>......</p>"
}

我想_reindex他们将所有数据转换为这样的新映射
{
    "title_1": {
        "en": "Test title",
        "ar": "عنوان تجريبي"
    },
    "body": "<p>......</p>"
}

在_reindex API中提供此转换的最佳 flex 搜索管道处理器是什么?

最佳答案

我建议只使用reindex API来做到这一点:

POST _reindex
{
  "source": {
    "index": "old_index"
  },
  "dest": {
    "index": "new_index"
  },
  "script": {
    "source": "ctx._source.title = [ 'en' : ctx._source.title, 'ar': ctx._source.title_ar]",
    "lang": "painless"
  }
}

如果在old_index索引中,您具有以下内容:
{
    "title": "Test title",
    "title_ar": "عنوان تجريبي",
    "body": "<p>......</p>"
}

在新索引中,将具有以下内容:
{
    "title": {
        "en": "Test title",
        "ar": "عنوان تجريبي"
    },
    "body": "<p>......</p>"
}

关于elasticsearch - 如何将Elasticsearch数据重新索引到新映射(从平面字段到对象)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56774906/

相关文章:

elasticsearch - grok不解析日志

elasticsearch - 如何在Elasticsearch中组合两个以上的过滤器?

php - 如何重新索引多维数组的所有子数组元素?

cron - 如何设置 Cronjob 以在 Docker 内重新索引 Magento 2

elasticsearch - 将仪表板上传到 Elasticsearch Kibana for Beats/To Beats

elasticsearch - 如何通过索引名称(通配符)搜索Elasticsearch索引列表

elasticsearch - 在 Elasticsearch 中相当于分组并作为列表收集的东西是什么?

python - Pandas 重新索引日期索引按组重新访问

dataframe - 重新索引数据帧时出现问题 : Reindexing only valid with uniquely valued Index objects

PostgreSQL - 添加新索引时重新索引