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.增减节点时, ...
随机推荐
- s2sh乱码一个小处理(新手按流程走)
解决乱码几小点: 1.配置过滤器,可以选择自己写,既然你用的SSH框架就更简单了,直接用Spring的过滤器,web.xml里配置一下即可. 2.Jsp页面设置编码,所有地方都要相同,我习惯用GBK ...
- HDU 5228 ZCC loves straight flush 暴力
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5228 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- 有关rand(),srand()产生随机数学习总结
看到夏雪冬日的有关rand()和srand()产生随机数的总结,挺好的,学习了,然后又有百度其他人的成果,系统总结一下.本文转自夏雪冬日:http://www.cnblogs.com/heyongga ...
- lintcode-202-线段树的查询
202-线段树的查询 对于一个有n个数的整数数组,在对应的线段树中, 根节点所代表的区间为0-n-1, 每个节点有一个额外的属性max,值为该节点所代表的数组区间start到end内的最大值. 为Se ...
- Kotlint集合简单总结
1.数组操作 var testArray = Array<>("s","ss")或者 = arrayOf("s","s ...
- QSharedMemory共享内存实现进程间通讯(IPC)及禁止程序多开
版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:QSharedMemory共享内存实现进程间通讯(IPC)及禁止程序多开 本文地址:h ...
- HDU5266-pog loves szh III
题目 给出一棵\(n\)个点的树,从1到\(n\)编号,\(m\)次询问\({LCA} _{v\in[L,R]}\). \(n,m\le 3\times 10^5\) 分析 我的做法是直接对LCA进 ...
- Python清理过期文件
改程序执行后,会清理 test/文件夹中距离现在超过一天的以 .xml 结尾的文件 # coding: utf-8 import time import os root = os.path.dirna ...
- 前端开发学习之——利用模板实现涉及url问题时的bug分析及解决(chrome源码)
例如我们要实现如下页面,其中历史页面列表想来自底层返回的数据,此处用testData代替: 最初我写的实现代码如下: html文件: <!doctype html> <html cl ...
- [SDOI2011]黑白棋 kth - nim游戏
题面 题面 题解 观察题目,我们可以发现,这个游戏其实就是不断再把对方挤到一边去,也就是黑子不断往左走,白子不断往右走. 因此可以发现,如果将黑白子按顺序两两配对,那么它们中间的距离会不断缩小,且每次 ...