1 常用endpoint
方式 endpoint 描述 PUT [index] 新建索引 请求体可参考:2.1 新建索引请求体样式 _template/[template] 添加模板 请求体可参考:2.2 新建模板请求体样式 [index]/[type]/[id] 添加数据,无[id]时,随机生成20位的id 请求体可参考:2.3 添加数据请求体样式 [index]/_settings 修改索引设置信息 请求体可参考:2.7 POST [index]/[type]/[id]
添加数据,无[id]时,随机生成20位的id 请求体可参考:2.3 添加数据请求体样式 _reindex 数据迁移 请求体可参考: 2.4 数据迁移请求体样式 [index]/_delete_by_query 基于查询的删除 请求体内容: DSL query查询语句 [index]/[type]/[id]/_update 更新数据 请求体可参考: 2.5 更新请求体样式 GET [index]/[type]/_search 查询索引中数据, [index],[type]可选,控制范围. 请求体内容 : DSL query查询语句 lib*/_search 查询所有相同前缀索引数据 _cat/indices 查询所有索引及容量 [index]/_mapping 查询索引映射结构,无[index]时,查所有映射信息 _all 查询所有索引映射结构 _template 查询所有模板 _template/[template] 查询指定模板 _cluster/health 查询集群健康状态 _cat/nodes 查询所有节点 _cat/shards 查询索引及分片的分布 _cat/plugins 查询所有插件 [index]/[type]/_count 查看文档数量 [index],[type]可选,控制范围 [index]/[type]/[id]/_source 不查询文档的元数据,只查询source部分的数据 [index]/[type]/_mget 取回多个文档,[index]/[type]可选,控制范围,请求体内容 2.6 mget请求体样式 [index]/_settings 查看索引设置信息,[index] 可选,控制范围 DELETE [index] 删除索引 [index]/[type]/[id] 通过id删除数据 _template/[template] 删除模板
2. 备注
2.1 新建索引请求体样式
{
"mappings": {
"doc": {
"properties": {
"name": {
"type": "text"
},
"blob": {
"type": "binary"
}
}
}
}
}
2.2 新建模板请求体样式
{
"template" : "my-*",
"order" : 0,
"settings" : {
"number_of_shards" : 10,
"number_of_replicas" : 0
},
"mappings": {
"default": {
"_all": {
"enabled": false
},
"properties": {
"name": {
"type": "text"
},
"age": {
"type": "long"
}
}
}
}
}
2.3 添加数据请求体样式
2.4 数据迁移请求体样式
{
"source": {
"index": "my_index"
},
"dest": {
"index": "new_my_index"
}
}
2.5 更新请求体样式
{
"doc":{
"name":"kyle",
"age":20
}
}
2.6 mget请求体样式
//可在endpoint中指定index type,也可在请求体中指定
{
"docs" : [
{
"_index" : "demo2",
"_type" : "system",
"_id" : 2,
"_source":[
"name"
]
}
]
}
//只指定index,可根据is查询
{
"ids":[1,2]
}
2.7 设置请求体样式
{
"index" : {
"number_of_replicas":0
}
}