示例以es6.x版本为例子,es5.x中type不支持以“_”开头
查看集群所有的索引:
GET /_cat/indices (GET /_cat/indices?v 增加?v显示头信息)
创建索引:
PUT /customer
插入文档(_doc为索引type,可任意命名):
PUT /customer/_doc/1
{
"name": "John Doe"
}
查询文档:
GET /customer/_doc/1
更新文档(实际是删除旧的文档,然后重新索引一个新的文档)
POST /customer/_doc/1/_update
{
"doc": { "name": "Jane Doe" }
}
删除文档(索引名称/索引type/id)
DELETE /customer/_doc/2
批处理
1)批量索引文档
POST /customer/_doc/_bulk
{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }
2)批量更新或删除
POST /customer/_doc/_bulk?pretty
{"update":{"_id":"1"}}
{"doc": { "name": "John Doe becomes Jane Doe" } }
{"delete":{"_id":"2"}}