批量向弹性搜索索引中的所有文档添加新字段 [英] Bulk add new field to ALL documents in an elasticsearch index

查看:112
本文介绍了批量向弹性搜索索引中的所有文档添加新字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在索引中为所有文档添加一个新的字段,而不需要拉下文档并将其推回(这将需要大约一天)。我有可能使用_BULK API来实现这一点吗?

I need to add a new field to ALL documents in an index without pulling down the document and pushing it back up (this will take about a day). Is it possible to use the _BULK api to achieve this?

我还研究了update_by_query插件,似乎只要把它们拉下来,他们回来了。

I have also researched the update_by_query plugin, and it seems to would take just as long as pulling them down and pushing them back myself.

推荐答案

是的,批量API支持更新,可以使用部分文档或脚本添加新字段。要遍历您的文档ID,请执行扫描并滚动使用 fields 参数集到一个空数组。

Yes, the bulk API supports updates which can add a new field using a partial document or script. To iterate through your document ids do a scan and scroll with the fields parameter set to an empty array.

这篇关于批量向弹性搜索索引中的所有文档添加新字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆