普通的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的更多相关文章

  1. Elasticsearch技术解析与实战 PDF (内含目录)

    Elasticsearch技术解析与实战                                  介绍: Elasticsearch是一个强[0大0]的搜索引擎,提供了近实时的索引.搜索.分 ...

  2. elasticsearch技术解析与实战ES

    elasticsearch技术解析与实战ES 下载地址: https://pan.baidu.com/s/1NpPX05C0xKx_w9gBYaMJ5w 扫码下面二维码关注公众号回复100008 获取 ...

  3. Elasticsearch技术解析与实战(七)Elasticsearch批量操作

    批量查询 1.如果查询的document是不同index下的不同type种的话 GET /_mget { "docs" : [ { "_index" : &qu ...

  4. Elasticsearch技术解析与实战(二)文档的CRUD操作

    启动Elasticsearch和kibana 访问Elasticsearch:http://localhost:9200/?pretty 访问kibana:http://localhost:5601 ...

  5. Elasticsearch技术解析与实战(一)基础概念及环境搭建

    序言 ES数据架构的主要概念(与关系数据库Mysql对比) 集群(cluster) 集群,一个ES集群由一个或多个节点(Node)组成,每个集群都有一个cluster name作为标识.一下是我们的4 ...

  6. Elasticsearch技术解析与实战(六)Elasticsearch并发

    乐观锁与悲观锁 图示的冲突过程,其实就是es的并发冲突问题,会导致数据不准确 当并发操作es的线程越多,或者读取一份数据,供用户查询和操作的时间越长,在这段时间里,如果数据被其他用户修改,那么我们拿到 ...

  7. elasticsearch技术解析与实战(一) 入门和索引

    GET _cat/nodes GET _cat/health GET _cat/shards GET http://10.37.84.124:9200/secisland?pretty { " ...

  8. Elasticsearch技术解析与实战(五)Document解析

    1.手动指定document id 一般来说,是从某些其他的系统中,导入一些数据到es时,会采取这种方式,就是使用系统中已有数据的唯一标识,作为es中document的id. PUT /index/t ...

  9. Elasticsearch技术解析与实战(四)shard&replica机制

    序言 shard&replica机制 1.index包含多个shard 2.每个shard都是一个最小工作单元,承载部分数据,lucene实例,完整的建立索引和处理请求的能力 3.增减节点时, ...

随机推荐

  1. HDU 5211 Mutiple 水题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5211 题解: 1.筛法: #include<iostream> #include< ...

  2. Hibernate(八)

    三套查询之Criteria查询 完全面向对象的,不需要写任可查询语句. 1.查询所有的学生 //1.查询所有的学生 @Test public void test1(){ Criteria criter ...

  3. Linux的压缩/解压缩文件处理 zip & unzip

    Linux的压缩/解压缩命令详解及实例 压缩服务器上当前目录的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前目录 unzip filename.zip 另:有些服 ...

  4. 【转】关于cgi、FastCGI、php-fpm、php-cgi

    转自 知乎 的 一个回答 首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的,方便CGI程序的编写者. web server(比如说nginx)只是内容的分发者.比如 ...

  5. 在dbgrid中如何多行选中记录(ctl与shift均可用)

    在dbgrid中如何多行选中记录(ctl与shift均可用),设置dbgrid的dgmultiselect为true,只有ctl好用而shift不好用,如何使shift也好用 Dbgrid源代码:pr ...

  6. resp.getWriter().print的注意点

  7. (转)maven下载jar包速度慢(解决办法)

    本文转载至http://blog.csdn.net/ko289830707/article/details/53559052 现在maven项目非常流行,因为它对jar实行了一个非常方便的管理,我们可 ...

  8. TortoiseSVN的基本使用方法

    TotoiseSVN的基本使用方法 来源 https://blog.csdn.net/hecongzhen/article/details/37879801 在 项目管理实践教程一.工欲善其事,必先利 ...

  9. 【转】.gitignore失效的解决办法

    转自:http://foreverdo.diandian.com/post/2012-09-20/40038034798 How to make .gitignore works? Just got ...

  10. WPF 如何加载图片

    Uri ri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources/exp.jpg"); ImageSource ...