一、指定ID
PUT /lib/user/1 //lib:索引 user :文档 1:id
{
"first_name":"Jane",
"last_name":"Smith",
"age":32,
"about":"I like to collect rock albums",
"insterests":["music"]
}
二、不指定id
POST /lib/user
{
"first_name":"Douglas",
"last_name":"Fir",
"age":35,
"about":"I like build",
"insterests":["forestry"]
}
三、查询
GET /lib/user/1 //查询*
GET /lib/user/1?_source=age,about //查询指定的字段
四、更新
PUT /lib/user/1 //覆盖的方式更新
{
"first_name":"Jane",
"last_name":"Smith",
"age":39,
"about":"I like to collect rock albums",
"insterests":["music"]
}
POST /lib/user/1/_update //直接修改
{
"doc": {
"age":30
}
}
五、删除
DELETE /lib/user/1 //删除用户id为1的用户
DELETE lib2 //删除索引