elasticsearch常用命令

官方文档

index操作

创建index

PUT
http://ip:port/{index}

获取指定index

GET
http://ip:port/{index}

获取所有的index

GET
http://ip:port/_cat/indices?v

删除指定index

DELETE
http://ip:port/{index}

doc操作

创建doc、全量修改doc

POST或PUT
http://ip:port/{index}/_doc/{id}

1
2
3
4
{
"id":1,
"name":"test"
}

查询指定doc

GET
http://ip:port/{index}/_doc/{id}

修改doc部分属性

POST
http://ip:port/{index}/_update/{id}

1
2
3
4
5
{
"doc":{
"name":"update"
}
}

删除doc

DELETE
http://ip:port/{index}/_doc/{id}

搜索doc

GET
http://ip:port/{index}/_search

1
2
3
4
5
{
"query": {
"match_all": {}
}
}

mapping

设置index mapping

PUT
http://ip:port/{index}/_mapping

1
2
3
4
5
6
7
8
9
10
{
"properties":{
"id":{
"type":"long"
},
"name":{
"type":"text"
}
}
}