添加文档 手动指定_id
POST /products/_doc/1
{
"id": 1,
"title": "小面包",
"price": 20.21,
"created": "2022-01-12",
"desc": "真的好吃!!!!!!"
}
添加文档 自动生成_id
POST /products/_doc
{
"id": 2,
"title": "小浣熊",
"price": 1.5,
"created": "2020-01-12",
"desc": "小浣熊真好吃!!!!!!"
}
查询文档 基于id
GET /products/_doc/4
删除文档 基于id
DELETE /products/_doc/o8FOTH4B_GJctjak9k_d
更新文档 (注意:该方法是先将原始文档删除,重新添加)
PUT /products/_doc/1
{
"id": 1,
"title": "法式小面包",
"price": 20.21,
"created": "2022-01-12",
"desc": "真的好吃!!!!!!"
}
更新文档 指定字段更新
POST /products/_doc/1/_update
{
"doc": {
"desc": "还是盼盼好"
}
}
批量添加
PUT /products/_doc/_bulk
{"index": {"_id": 2}}
{"id": 2,"title": "德芙","price": 20.21,"created": "2022-01-12","desc": "纵享丝滑"}
{"index": {"_id": 3}}
{"id": 3,"title": "水晶葡萄","price": 4.00,"created": "2021-01-12","desc": "真好喝"}
批量操作 添加 更新删除
PUT /products/_doc/_bulk
{"index": {"_id": 4}}
{"id": 4,"title": "甜不辣","price": 10.21,"created": "2022-01-12","desc": "甜不辣真好吃"}
{"update": {"_id": 2}}
{"doc": {"title": "德芙巧克力"}}
{"delete": {"_id": 3}}
评论区