elastic search dev tool

索引

查询所有索引

1
2
GET /_cat/indices
{}

搜索

所有数据

1
2
3
4
5
6
7
GET /<index>/_search
{
"query": {
"match_all": {},
"track_total_hits": true
}
}

track_total_hits=true 返回准确的数量,不然 total.value 最大返回 10000

搜索字段

1
2
3
4
5
6
7
8
GET /<index>/_search
{
"query": {
"match": {
"<filed>": "<value>"
}
}
}

正则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
GET /<index>/_search
{
"query": {
"regexp": {
"<filed>": "<regepx>"
}
}
}

# 不为空
{
"query": {
"regexp": {
"<filed>": ".+"
}
}
}

有值

1
2
3
4
5
6
7
8
GET /_search
{
"query": {
"exists": {
"field": "<field>"
}
}
}

更新数据

1
2
3
4
5
6
POST /<index>/_update/<id>
{
"doc": {
"<field>": "<value>"
}
}

索引

创建索引

1
2
3
4
5
6
7
8
9
10
11
12
13
PUT /<new-index>
{
"settings": {
"index.store.type": "mmapfs",
"index.refresh_interval": "1s",
"index.number_of_replicas": "5",
"index.number_of_shards": "2",
"index.max_result_window": "5000000"
},
"mappings": {
"date_detection": true
}
}

删除索引

1
2
3
DELETE /<index>
{
}

重建索引

1
2
3
4
5
6
7
8
9
POST _reindex
{
"source": {
"index": "<source-index>"
},
"dest": {
"index": "<dest-index>"
}
}