Elasticsearch技术解析与实战(七)Elasticsearch partial update
普通的partial update
1.插入测试数据
PUT /test_index/test_type/10
{
"test_field1": "test1",
"test_field2": "test2"
}
2.更新
POST /test_index/test_type/10/_update
{
"doc": {
"test_field2": "updated test2"
}
}
基于groovy脚本执行partial update
1.内置脚本
插入测试数据
PUT /test_index/test_type/11
{
"num": 0,
"tags": []
}
更新
POST /test_index/test_type/11/_update
{
"script" : "ctx._source.num+=1"
}
2.外部脚本
更新

POST /test_index/test_type/11/_update
{
"script": {
"lang": "groovy",
"file": "test-add-tags",
"params": {
"new_tag": "tag1"
}
}
}
用脚本删除文档

POST /test_index/test_type/11/_update
{
"script": {
"lang": "groovy",
"file": "test-delete-document",
"params": {
"count": 1
}
}
}
upsert操作
POST /test_index/test_type/11/_update
{
"script" : "ctx._source.num+=1",
"upsert": {
"num": 0,
"tags": []
}
}
partial update内置乐观锁并发控制
post /index/type/id/_update?retry_on_conflict=5&version=6
Elasticsearch技术解析与实战(七)Elasticsearch partial update的更多相关文章
- Elasticsearch技术解析与实战 PDF (内含目录)
Elasticsearch技术解析与实战 介绍: Elasticsearch是一个强[0大0]的搜索引擎,提供了近实时的索引.搜索.分 ...
- elasticsearch技术解析与实战ES
elasticsearch技术解析与实战ES 下载地址: https://pan.baidu.com/s/1NpPX05C0xKx_w9gBYaMJ5w 扫码下面二维码关注公众号回复100008 获取 ...
- Elasticsearch技术解析与实战(七)Elasticsearch批量操作
批量查询 1.如果查询的document是不同index下的不同type种的话 GET /_mget { "docs" : [ { "_index" : &qu ...
- Elasticsearch技术解析与实战(二)文档的CRUD操作
启动Elasticsearch和kibana 访问Elasticsearch:http://localhost:9200/?pretty 访问kibana:http://localhost:5601 ...
- Elasticsearch技术解析与实战(一)基础概念及环境搭建
序言 ES数据架构的主要概念(与关系数据库Mysql对比) 集群(cluster) 集群,一个ES集群由一个或多个节点(Node)组成,每个集群都有一个cluster name作为标识.一下是我们的4 ...
- Elasticsearch技术解析与实战(六)Elasticsearch并发
乐观锁与悲观锁 图示的冲突过程,其实就是es的并发冲突问题,会导致数据不准确 当并发操作es的线程越多,或者读取一份数据,供用户查询和操作的时间越长,在这段时间里,如果数据被其他用户修改,那么我们拿到 ...
- elasticsearch技术解析与实战(一) 入门和索引
GET _cat/nodes GET _cat/health GET _cat/shards GET http://10.37.84.124:9200/secisland?pretty { " ...
- Elasticsearch技术解析与实战(五)Document解析
1.手动指定document id 一般来说,是从某些其他的系统中,导入一些数据到es时,会采取这种方式,就是使用系统中已有数据的唯一标识,作为es中document的id. PUT /index/t ...
- Elasticsearch技术解析与实战(四)shard&replica机制
序言 shard&replica机制 1.index包含多个shard 2.每个shard都是一个最小工作单元,承载部分数据,lucene实例,完整的建立索引和处理请求的能力 3.增减节点时, ...
随机推荐
- Alpha冲刺——第八天
Alpha第八天 听说 031502543 周龙荣(队长) 031502615 李家鹏 031502632 伍晨薇 031502637 张柽 031502639 郑秦 1.前言 任务分配是VV.ZQ. ...
- springboot+vue+element:echarts开发遇见问题---vue前端(二)
<template> <u-grid> <u-grid-item caption="服务使用统计排行"> <div class=" ...
- android入门 — ProgressDialog/DatePickerDialog/TimePickerDialog
这三个Dialog都是AlertDialog的子类. ①DatePickerDialog 1.创建DatePickerDialog的实例: 2.通过Calendar类获得系统时间: 3.通过DateP ...
- ArrayList和LinkedList源码分析
ArrayList 非线程安全 ArrayList内部是以数组存储元素的.类有以下变量: /*来自于超类AbstractList,使用迭代器时可以通过该值判断集合是否被修改*/ protected t ...
- google auth
思路: secret 系统生成的密钥 把密钥分配给某个用户,用户可以把这个密钥加入到app中,app会1min生成一个code: 验证时,根据用户的 secret ,系统生成一个code,再比较用户输 ...
- ajax跨域问题(三种解决方案)
为什么会出现跨域 跨域问题来源于JavaScript的同源策略,即只有 协议+主机名+端口号 (如存在)相同,则允许相互访问.也就是说JavaScript只能访问和操作自己域下的资源,不能访问和操作其 ...
- docker 开启远程
# vi /etc/init.d/docker 在start()中加入:$exec -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock -d & ...
- CSS布局-垂直居中问题
在前端页面的布局方面,很多时候需要用到垂直居中,如果父集元素或子元素的高度是固定的那么垂直居中可以用line-height或者定位 top:50%:margin-top:- height/2 px:实 ...
- 题解 P1420 【最长连号】
这个题过去的同学可以再来一题(P1567 统计天数): https://www.luogu.org/problemnew/show/P1567 是的,这个题其实也不是很难,就是前后比较,将天数压栈, ...
- 【转】小心stringstream.str()字符串用法的陷阱
--------------------- 作者:心中那自由的世界 来源:CSDN 原文:https://blog.csdn.net/119365374/article/details/7744678 ...