Elasticsearch 入门 - Modifying Your Data
index/update/delete 均有大概1秒的缓存时间
Indexing/Replacing Documents
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
replace/reindex:
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Jane Doe"
}
'
Index a new document with and ID of 2:
curl -X PUT "localhost:9200/customer/_doc/2?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Jane Doe"
}
'
Index a document without an explicit ID:
curl -X POST "localhost:9200/customer/_doc?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Jane Doe"
}
'
Updating Documents
Elasticsearch 的更新操作并非原位更新数据,不管什么时候更新操作都是删除旧文档后再索引新的文档。
将ID为1的文档name字段更新为 "Jane Doe":
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"doc": { "name": "Jane Doe" }
}
'
将ID为1的文档name字段更新为 "Jane Doe"的同时添加一个age字段:
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"doc": { "name": "Jane Doe", "age": 20 }
}
'
更新操作能够执行简单的脚本,例如使用脚本将age加5:
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"script" : "ctx._source.age += 5"
}
'
其中 ctx._source 指向当前需要被更新的文档。
Deleting Documents
删除ID为2的文档:
curl -X DELETE "localhost:9200/customer/_doc/2?pretty"
Elasticsearch 入门 - Modifying Your Data的更多相关文章
- 《读书报告 -- Elasticsearch入门 》-- 安装以及简单使用(1)
<读书报告 – Elasticsearch入门 > 第一章 Elasticsearch入门 Elasticsearch是一个实时的分布式搜索和分析引擎,使得人们可以在一定规模上和一定速度上 ...
- ElasticSearch入门 第二篇:集群配置
这是ElasticSearch 2.4 版本系列的第二篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...
- ElasticSearch入门 第六篇:复合数据类型——数组,对象和嵌套
这是ElasticSearch 2.4 版本系列的第六篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...
- ElasticSearch入门 第八篇:存储
这是ElasticSearch 2.4 版本系列的第八篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...
- ElasticSearch入门 第三篇:索引
这是ElasticSearch 2.4 版本系列的第三篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...
- Elasticsearch入门教程(五):Elasticsearch查询(一)
原文:Elasticsearch入门教程(五):Elasticsearch查询(一) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:h ...
- 转载:elasticsearch入门篇
转自:https://www.cnblogs.com/hello-shf/p/11543408.html elasticsearch入门篇 elasticsearch专栏:https://www. ...
- Elasticsearch入门教程(一):Elasticsearch及插件安装
原文:Elasticsearch入门教程(一):Elasticsearch及插件安装 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:h ...
- Elasticsearch入门,看这一篇就够了
目录 前言 可视化工具 kibana kibana 的安装 kibana 配置 kibana 的启动 Elasticsearch 入门操作 操作 index 创建 index 索引别名有什么用 删除索 ...
随机推荐
- HDU 4511
SHIT,SHIT,SHIT,SHIT,SHIT... 这道题可以使用AC自动机+DP来解决.也就是用非法路径建立TRIE图,然后从trie[root][1]点开始广搜DP即可.千万要注意一点,题目里 ...
- HDU 4531
很容易判断是BFS,可是,呵呵呵呵呵呵......... HASH判重吧,判连通可以用并查集. 以下代码是转别人的,我码了一下午,发觉越码越丑,呵呵了. http://www.cnblogs.com/ ...
- jQuery学习之开篇
吐槽 近期比較烦,对于一个前端白痴来说,工作方向突然转向前端这块着实让人蛋疼无比.前段时间简单的学习了下EasyUI,算是对其有一个简单的认知了吧.EasyUI的研究过程中发现,假设没有掌握JS.JQ ...
- swing Jlable中存放变量显示问题
java swing 学习 在做一个ATM机系统小案例中.碰到JLable中存放变量,变量发生改变.而JLable中还是显示原来的值,网上寻找答案,用updateUI()和revalidate();方 ...
- 【待解决】maven创建web报Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins
Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:maven-war-plugin:maven- ...
- 驱动开发(8)处理设备I/O控制函数DeviceIoControl
本博文由CSDN博主zuishikonghuan所作,版权归zuishikonghuan全部,转载请注明出处:http://blog.csdn.net/zuishikonghuan/article/d ...
- 辨异 —— Java 中的抽象类和接口
接口优于抽象类.-- <Effective Java>(Item 18) 0. 语法区别 抽象类允许给出某些方法的实现,接口不允许: 为了实现由抽象类定义的类型(type),类必须成为抽象 ...
- Node.js:REPL(交互式解释器)
ylbtech-Node.js:REPL(交互式解释器) 1.返回顶部 1. Node.js REPL(交互式解释器) Node.js REPL(Read Eval Print Loop:交互式解释器 ...
- jdk5可变参数列表
今天碰到了 public static String getAutoRelateRelationship(final JSONObject modifyJson, String... inUsedCo ...
- 如何让音频跟视频在ios跟android上自动播放
如何让音频跟视频在ios跟android上自动播放 <audio autoplay ><source src="audio/alarm1.mp3" type=&q ...