多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] # 创建 ![](https://img.kancloud.cn/b3/bb/b3bb300902e89c67798c822c63df70b7_417x406.png) ID你可以不设置,不设置他会帮你设置一个的 ~~~ POST /library/books/ { "title": "Elasticsearch : the definitive guide", "name": { "first": "Vineeth", "last": "Mohan" }, "publish_date": "2015-02-06", "price":"35.99" } ~~~ 返回结果中有个\_id的,那就是es帮你设置的 # 查询 ~~~ GET /library/books/1 GET /library/books/2 ~~~ 可以通过source获取指定的字段 ~~~ GET /library/books/1?_source=title,price ~~~ # 更新 我们更新同一个id下的文档,可以通过覆盖更新 ~~~ PUT /library/books/1 { "title": "Elasticsearch : the definitive guide", "name": { "first": "Vineeth", "last": "Mohan" }, "publish_date": "2015-02-06", "price":"25.99" } ~~~ 查询下 ~~~ GET /library/books/1 ~~~ 或者通过`_update`这个api方式单独更新你想更新的字段 ~~~ POST /library/books/1/_update { "doc": { "price": 10 } } POST /library/books/1/_update { "doc": { "title": "fly" } } ~~~ # 删除 ~~~ DELETE /library/books/1 ~~~ 复制 然后我们GET下,看下结果 发现found是false ~~~ { "_index": "library", "_type": "books", "_id": "1", "found": false } ~~~ 也可以删除type ~~~ DELETE /library/books ~~~ 也可以删除索引 ~~~ DELETE /library ~~~