elasticsearch Document相关操作记录
elasticsearch restful    2017-07-19 20:41:59    2   
lightingfire   elasticsearch restful
为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。
elasticsearch:2.3

----------------------------------------创建文章---------------------------------------------
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}
----------------------------------------查询文章---------------------------------------------


 -- 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" ]
  }
}

----------------------------------------修改文章---------------------------------------------
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}


----------------------------------------查询文章---------------------------------------------

 -- 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" ]
  }
}

----------------------------------------删除文章---------------------------------------------

 -- 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}}

----------------------------------------查询文章---------------------------------------------


 -- response --
404 Not Found
Content-Type:  application/json; charset=UTF-8
Content-Length:  64

{"_index":"megacorp","_type":"employee","_id":"1","found":false}

 

by 刘迎光@萤火虫工作室 
OpenBI交流群:495266201 
MicroService 微服务交流群:217722918 
mail: liuyg#liuyingguang.cn 
博主首页(==防止爬虫==):http://blog.liuyingguang.cn

Pre: saiku2.x刷新缓存的方法

Next: Mondrian 4 测试的简单demo(Saiku简单测试Schema文件)


Table of content