在安装kibana(安装过程详见:https://blog.csdn.net/yanyf2016/article/details/103925273)之后,打开找到Dev Tools
#创建索引
PUT /lib/
{
"settings": {
"index":{
"number_of_shards":5,
"number_of_replicas":0
}
}
}
PUT lib2
#查看索引配置
GET /lib/_settings
GET /lib2/_settings
GET _all/_settings
#创建索引之后就可以在索引之下添加文档
#指定id用put
PUT /lib/user/1
{
"first_name":"jame",
"last_name":"smith",
"age":33,
"about": "I like to collent rock albums",
"interests":["music"]
}
#不指定id用post,id由elasticsearch生成
POST /lib/user/
{
"first_name":"jame",
"last_name":"smith",
"age":33,
"about": "I like to collent rock albums",
"interests":["music"]
}
#查询文档所有信息
GET /lib/user/1
GET /lib/user/_oVuj28Bo8RJqkNDiyCj
#查询文档部分信息
GET /lib/user/1?_source=age,about
#覆盖方式更新
PUT /lib/user/1
{
"first_name":"jame",
"last_name":"tom",
"age":36,
"about": "I like to collent rock albums",
"interests":["snook"]
}
#直接更新
POST /lib/user/1/_update
{
"doc":{
"age":22
}
}
#删除文档
DELETE /lib/user/1
#删除索引
DELETE lib2
#批量获取文档全部信息
GET /_mget
{
"docs":[
{
"_index":"lib",
"_type":"user",
"_id":1
},
{
"_index":"lib",
"_type":"user",
"_id":2
},
{
"_index":"lib",
"_type":"user",
"_id":3
}
]
}
#批量获取文档指定信息
GET /_mget
{
"docs":[
{
"_index":"lib",
"_type":"user",
"_id":1,
"_source":"interests"
},
{
"_index":"lib",
"_type":"user",
"_id":2,
"_source":["age","interests"]
}
]
}
#获取相同索引相同类型下的文档
GET /lib/user/_mget
{
"docs":[
{
"_id":1
},
{
"_type":"user",
"_id":2
}
]
}
#更简单的写法
GET /lib/user/_mget
{
"ids":["1","2"]
}