elasticsearch Document相关操作记录
2016-07-12 15:03
393 查看
为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。
elasticsearch:2.3
----------------------------------------创建文章---------------------------------------------
PUT http://192.168.10.139:9200/megacorp/employee/1
Content-Type: application/json
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 127
{"_index":"megacorp","_type":"employee","_id":"1","_version":6,"_shards":{"total":2,"successful":1,"failed":0},"created":false}
----------------------------------------查询文章---------------------------------------------
GET http://192.168.10.139:9200/megacorp/employee/1?pretty
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 278
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_version" : 6,
"found" : true,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests" : [ "sports", "music" ]
}
}
----------------------------------------修改文章---------------------------------------------
PUT http://192.168.10.139:9200/megacorp/employee/1
Content-Type: application/json
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
-- response --
201 Created
Content-Type: application/json; charset=UTF-8
Content-Length: 126
{"_index":"megacorp","_type":"employee","_id":"1","_version":8,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
----------------------------------------查询文章---------------------------------------------
GET http://192.168.10.139:9200/megacorp/employee/1?pretty
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 278
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_version" : 8,
"found" : true,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests" : [ "sports", "music" ]
}
}
----------------------------------------删除文章---------------------------------------------
DELETE http://192.168.10.139:9200/megacorp/employee/1
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 124
{"found":true,"_index":"megacorp","_type":"employee","_id":"1","_version":7,"_shards":{"total":2,"successful":1,"failed":0}}
----------------------------------------查询文章---------------------------------------------
GET http://192.168.10.139:9200/megacorp/employee/1
-- response --
404 Not Found
Content-Type: application/json; charset=UTF-8
Content-Length: 64
{"_index":"megacorp","_type":"employee","_id":"1","found":false}
本文所用测试工具:火狐插件HttpRequester。
elasticsearch:2.3
----------------------------------------创建文章---------------------------------------------
PUT http://192.168.10.139:9200/megacorp/employee/1
Content-Type: application/json
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 127
{"_index":"megacorp","_type":"employee","_id":"1","_version":6,"_shards":{"total":2,"successful":1,"failed":0},"created":false}
----------------------------------------查询文章---------------------------------------------
GET http://192.168.10.139:9200/megacorp/employee/1?pretty
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 278
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_version" : 6,
"found" : true,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests" : [ "sports", "music" ]
}
}
----------------------------------------修改文章---------------------------------------------
PUT http://192.168.10.139:9200/megacorp/employee/1
Content-Type: application/json
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
-- response --
201 Created
Content-Type: application/json; charset=UTF-8
Content-Length: 126
{"_index":"megacorp","_type":"employee","_id":"1","_version":8,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
----------------------------------------查询文章---------------------------------------------
GET http://192.168.10.139:9200/megacorp/employee/1?pretty
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 278
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_version" : 8,
"found" : true,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests" : [ "sports", "music" ]
}
}
----------------------------------------删除文章---------------------------------------------
DELETE http://192.168.10.139:9200/megacorp/employee/1
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 124
{"found":true,"_index":"megacorp","_type":"employee","_id":"1","_version":7,"_shards":{"total":2,"successful":1,"failed":0}}
----------------------------------------查询文章---------------------------------------------
GET http://192.168.10.139:9200/megacorp/employee/1
-- response --
404 Not Found
Content-Type: application/json; charset=UTF-8
Content-Length: 64
{"_index":"megacorp","_type":"employee","_id":"1","found":false}
相关文章推荐
- maven导入本地jar包
- dyld: Library not loaded: @rpath/MySDK.framework/MySDK 错误解决
- hdu 1050 Moving Tables
- mysql 忘记密码
- raw图片转成png
- 天下所有的事,都是为了利益,都是按利益逻辑规律在运行,发生的一切事情都可以用利益逻辑来解释
- Ehcache 整合Spring 使用页面、对象缓存
- Find a path
- glGenVertexArrays 或glBindVertexArray 暴力访问
- 将R的Shiny App部署到网上遇到的一些坑QAQ
- Java 通过JDBC连接Mysql数据库
- myeclipse中文乱码
- Python内置函数清单
- 数据库自动生成行数
- poj 3264 线段树 入门
- Yelp API(v2) with Mode.js support--handling of authentication
- Yii视图CGridView列表用法实例分析
- Hadoop-2.0命令手册
- wpf 转换器(枚举类型和布尔类型绑定)
- 接口篇(5.2) 04. 调整 DHCP 租约时间 ❀ 飞塔 (Fortinet) 防火墙