【ElasticSearch 6.*】 学习六:数据修改

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31617637/article/details/85104235

直接修改

请求参数 (POSThttp://localhost:9200/people/man/1/_update

//要修改的文本 doc关键字
{
	"doc":{
		"name" :"libaba"
	}
}

返回值:

{
    "_index": "people",
    "_type": "man",
    "_id": "1",
    "_version": 2,
    "result": "updated",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    },
    "_seq_no": 2,
    "_primary_term": 1
}

在这里插入图片描述
在这里插入图片描述

脚本修改

请求参数 (POSThttp://localhost:9200/people/man/1/_update

//要修改的文本 script关键字  指定脚本语言 将id为1的age增加10
{
	"script":{
		"lang" :"painless",
		"inline": "ctx._source.age += 10"
	}
}

或者定义参数的请求值:

{
	"script":{
		"lang" :"painless",
		"inline": "ctx._source.age  = params.age",
		"params":{
			"age" : 100
		}
	}
}

返回参数:

{
    "_index": "people",
    "_type": "man",
    "_id": "1",
    "_version": 3,
    "result": "updated",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    },
    "_seq_no": 3,
    "_primary_term": 1
}

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_31617637/article/details/85104235