是否可以在弹性搜索中重新索引索引下的所有文档

时间:2019-08-29 01:56:28

标签: elasticsearch

我的弹性搜索索引包含1亿个文档。由于我使用流媒体工具进行了批量上传,因此ID是自动生成的。弹性搜索是否提供任何api,以针对特定索引下的所有记录,使用弹性搜索文档中现有的id字段之一来更新文档ID(_id)。

我从https://discuss.elastic.co/t/how-to-change-a-documents--id-during-a-reindex/76132尝试了以下方法,但仅更新了一条记录。

POST /_reindex
{
  "source": {
"remote": {
  "host": "<old-host>:9200"
},
"index": "buildserver",
"type": "build",
"_source": true
  },
  "dest": {
    "index": "buildserver",
    "version_type": "internal"
  },
  "script": {
    "lang": "painless",
    "inline": "ctx._source._id = ctx._source['Branch'] + '-' + 
 ctx._source['BuildNumber']"
 }
}

0 个答案:

没有答案