【发布时间】:2018-06-25 16:23:36
【问题描述】:
这是我在 elasticsearch 中的一份文档:
{
"_index": "2017-10-21",
"_type": "cat",
"_id": "14",
"_score": 2.2335923,
"_source": {
"name": "Biscuit",
"breed": "Persian",
"age": "3"
}
}
我知道可以通过POST update 向现有文档添加新字段:
POST [index] / [type] / [id] / _update
例如,如果我想在我的文档中添加一个新字段“hairy”:
POST 2017-10-21 / cat / 14 / _update
{
"script" : "ctx._source.hairy = 'yes'"
}
我会得到这个结果:
{
"_index": "2017-10-21",
"_type": "cat",
"_id": "14",
"_source": {
"name": "Biscuit",
"breed": "Persian",
"age": "3",
"hairy": "yes"
}
}
但是,我想为我的所有文档添加一个新字段,无论它们的索引、类型或 ID 是什么。不幸的是,即使经过数小时的研究,我也没有找到一种方法来在不使用索引、类型或 id 的情况下执行POST update。
所以,我的问题是:这有可能吗?如果不是,还有其他方法可以做我想做的事吗?
提前感谢您提供的任何帮助!
【问题讨论】:
-
这个答案可能会有所帮助:stackoverflow.com/questions/32931757/…
-
谢谢@Val 我终于通过你的链接找到了解决方案!
标签: elasticsearch post