您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch更新api(类似mysql的自增)
发布时间:2021-08-31 21:22:35编辑:雪饮阅读()
现在我想要这个字段的值变成2004,也就是它自身增加4个单位。
则在elasticSearch中可以这样做:
请求正文:
{
"script" : {
"source": "ctx._source.fees += params.fees",
"lang": "painless",
"params" : {
"fees" : 4
}
}
}
响应结果:
{
"_index": "schools",
"_type": "_doc",
"_id": "1",
"_version": 6,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 7,
"_primary_term": 1
}
这个看着标记为黄色的部分,就很容易弄懂它了。
也可以参考链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
关键字词:elasticSearch,更新api,自增