🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 创建文档 格式 ``` POST /api/:target/_doc ``` 示例 ``` POST http://localhost:4080/api/hello2/_doc ``` 请求体 ``` { "name": "Prabhat Sharma", "age":12 } ``` 如果数据存在主键,则可使用_id 字段进行添加 ``` { "_id":"1", "name": "Prabhat Sharma", "age":12 } ``` ## 创建文档带ID 格式 ``` PUT /api/:target/_doc/:id ``` 示例 ``` PUT http://localhost:4080/api/hello2/_doc/1 ``` 请求提 ``` { "name": "Prabhat Sharma", "age":12 } ``` > 除了添加`_id`字段外,也可以在添加的时候,写在url path 下,效果相同 ## 更新 示例 ``` POST http://localhost:4080/api/myindex/_update/1 ``` 请求体 ``` { "id":"1", "name": "Prabhat Sharma", "age":15 } ``` > 更新时,只能全部字段一块更新,否则之后保留此次更新的字段 ## 批量加入 示例 ``` POST /api/_bulkv2 ``` ``` { "index" : "hello2", "records": [ {"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HAJOS, Alfred", "Country": "HUN", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Gold", "Season": "summer"}, {"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HERSCHMANN, Otto", "Country": "AUT", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Silver", "Season": "summer"}, {"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "CHASAPIS, Spiridon", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Silver", "Season": "summer"} ] } ```