elasticsearch入门学习
来源:互联网 发布:iea数据公布 编辑:程序博客网 时间:2024/05/24 06:30
一,索引添加
curl -X PUT 'http://localhost:9200//website/blog/123' -d'
{
"title": "My first blog entry",
"text": "Just trying this out...",
"date": "2014/01/01"
}'
二 查询
curl -X GET http://localhost:9200//website/blog/124?pretty
//pretty参数对查询结果输出进行优化
{ "_index" : "website", "_type" : "blog", "_id" : "123", "_version" : 1, "found" : true, "_source":{ "title": "My first blog entry", "text": "Just trying this out...", "date": "2014/01/01"}}
curl -X GET http://localhost:9200//website/blog/124?pretty_source=title,text //对_source字段进行过来
{ "_index": "website", "_type": "blog", "_id": "123", "_version": 1, "found": true, "_source": { "title": "My first blog entry", "text": "Just trying this out...", "date": "2014/01/01" }}
三 查看文档是否存在,而不关心文件内容 (curl -i -XHEAD http://localhost:9200/website/blog/123) -i -XHEAD
HTTP/1.1 200 OK
curl -i -XHEAD http://localhost:9200/website/blog/124
HTTP/1.1 404 Not Found
四 简单文档更新(下面只能下date字段)
curl -X PUT 'http://localhost:9200//website/blog/123' -d'
{
"title": "My first blog entry",
"text": "Just trying this out...",
"date": "2014/01/02"
}'
查询数据(发现_verssion字段变成2在内部,Elasticsearch已经标记旧文档为删除并添加了一个完整的新文档。旧版本文档不会立即消失,但你也不能去访问它。Elasticsearch会在你继续索引更多数据时清理被删除的文档。
{ "_index": "website", "_type": "blog", "_id": "123", "_version": 2, "found": true, "_source": { "title": "My first blog entry", "text": "Just trying this out...", "date": "2014/01/02" }}
五 文档删除(curl -XDELETE 'http://localhost:9200//website/blog/123')
{"found":true,"_index":"website","_type":"blog","_id":"123","_version":3}
六,修改外部版本号
PUT /website/blog/2?version=10&version_type=external{ "title": "My first external blog entry", "text": "This is a piece of cake..."}请求成功的设置了当前_version为10:{ "_index": "website", "_type": "blog", "_id": "2", "_version": 10, "created": false}
七 update文档
最简单的update请求表单接受一个局部文档参数doc,它会合并到现有文档中——对象合并在一起,存在的标量字段被覆盖,新字段被添加。举个例子,我们可以使用以下请求为博客添加一个tags字段和一个views字段:POST /website/blog/1/_update{ "doc" : { "tags" : [ "testing" ], "views": 0 }}
- elasticsearch学习入门
- Elasticsearch 入门学习笔记
- elasticsearch入门学习
- elasticsearch学习入门
- elasticsearch入门学习备忘
- Elasticsearch学习笔记(二)Elasticsearch入门
- ElasticSearch学习教程(一) 入门安装
- ElasticSearch入门
- ElasticSearch入门
- ElasticSearch入门
- ElasticSearch 入门
- Elasticsearch入门
- ElasticSearch 入门
- elasticsearch入门
- ElasticSearch 入门
- Elasticsearch入门
- elasticsearch入门
- ElasticSearch入门
- C#121课的主要内容
- 利用select异步I/O模型实现群聊
- windows+tersonflow+anaconda+pycharm
- 新人报道
- ZOJ-3785 What day is that day?
- elasticsearch入门学习
- adb、adb shell am、adb shell pm命令的详细使用说明
- ACM程序设计书中题目--B(字典问题)
- Deep Learning-TensorFlow (3) CNN卷积神经网络_AlexNet前瞻
- git操作教程及命令库
- 下面哪些机制可以用于进程间通信
- QT之HelloWorld
- 【BZOJ】1022: [SHOI2008]小约翰的游戏John
- 万圣节后的早晨