https://www.elastic.co/guide/cn/elasticsearch/guide/current/partial-updates.html
elasticsearch _update更新部分字段内容
update 请求最简单的一种形式是接收文档的一部分作为 doc 的参数, 它只是与现有的文档进行合并。对象被合并到一起,覆盖现有的字段,增加新的字段。
POST /website/blog/1/
{
"title": "My first blog entry",
"text": "Just trying this out..."
}
例如,我们增加字段 tags 和 views 到我们的博客文章,如下所示:
POST /website/blog/1/_update
{
"doc" : {
"tags" : [ "testing" ],
"views": 0
}
}
删除字段
POST /index/type/1/_update
{
"script" : "ctx._source.remove(\"name\")"
}
批量删除
POST /index/type/_update_by_query
{
"script" : "ctx._source.remove(\"name\")",
"query": {
"bool": {
"must": [
{
"exists": {
"field": "name"
}
}
]
}
}
}
删除mapping 里面的字段,目前还不支持,只能建立新的mapping了
本文详细介绍了在Elasticsearch中如何使用Update API更新文档的部分字段,包括添加新字段、修改现有字段及删除指定字段的方法。同时,还提供了批量删除字段的示例,并解释了为何无法直接删除mapping中的字段。

1239

被折叠的 条评论
为什么被折叠?



