码迷,mamicode.com
首页 > Windows程序 > 详细

elasticsearch REST api

时间:2017-08-14 14:24:57      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:就会   size   指定   balance   bank   from   ast   index   erb   

elasticsearch REST api
========================================
命令模式:<REST Verb> /<Index>/<Type>/<ID>




插入索引
------------
PUT /customer?pretty

查询索引列表
-------------
GET /_cat/indices?v

给索引插入文档
-----------------------
PUT /customer/external/1?pretty
{
  "name": "John Doe"
}

查询文档
---------------
GET /customer/external/1?pretty

删除索引
------------
DELETE /customer?pretty


修改文档
-------------
如果index/type/id 相同,就会替换文档
PUT /customer/external/1?pretty
{
  "name": "Jane Doe"
}

不指定ID插入文档
----------------------
POST /customer/external?pretty
{
  "name": "Jane Doe"
}

更新文档
---------------
POST /customer/external/1/_update?pretty
{
  "doc": { "name": "Jane Doe", "age": 20 }
}

POST /customer/external/1/_update?pretty
{
  "script" : "ctx._source.age += 5"
}

批量操作
------------
POST /customer/external/_bulk?pretty
{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }

POST /customer/external/_bulk?pretty
{"update":{"_id":"1"}}
{"doc": { "name": "John Doe becomes Jane Doe" } }
{"delete":{"_id":"2"}}

根据索引查询
-----------------
GET /bank/_search
{
  "query": { "match_all": {} },
  "size": 1
}

GET /bank/_search
{
  "query": { "match_all": {} },
  "from": 10,
  "size": 10
}

GET /bank/_search
{
  "query": { "match_all": {} },
  "sort": { "balance": { "order": "desc" } }
}

elasticsearch REST api

标签:就会   size   指定   balance   bank   from   ast   index   erb   

原文地址:http://www.cnblogs.com/zhaojonjon/p/7357344.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!