返回顶部
扶摇直上九万里,展翅高飞岂可待。

1、elasticsearch基本操作

## Elasticsearch中常用curl命令
 
1.查看集群状态
 
```
curl --location --request GET 'http://192.168.22.92:9200/_cluster/health?pretty'
```
 
2.查看节点状态
 
```
curl --location --request GET 'http://192.168.22.92:9200/_cat/nodes?pretty'
```
 
3.查看分片状态
 
```
curl --location --request GET 'http://192.168.22.92:9200/_cat/shards?pretty'
```
 
4.查看索引列表
 
```
curl --location --request GET 'http://192.168.22.92:9200/_cat/indices'
```
 
5.查看索引详细信息
 
```
curl --location --request GET 'http://192.168.249.4:9200/newgroupuser/_stats?pretty'
```
 
6.查看指定索引的文档数量
 
```
curl --location --request GET 'http://192.168.249.4:9200/usernetwork/_mapping'
```
 
7.查看指定索引mapping
 
```
curl --location --request GET 'http://10.247.19.20:9200/textmessage/_mapping?pretty'
```
 
8.查看指定索引的settings
 
```
curl --location --request GET 'http://192.168.22.92:9200/newgroupuser/_settings?pretty'
```
 
9.查询数据
 
```
curl --location --request GET 'http://10.247.19.20:9200/org/_search?pretty'
```
 
10.通过文档id查询数据
 
```
curl --location --request GET 'http://192.168.22.92:9200/newgroupuser/doc/c2b157e5-d466-4bb3-9c10-99cba8c513c9_ext'
```
 
11.搜索群组
 
```
curl --location --request GET 'http://192.168.249.4:9200/usernetwork/_search?pretty' \
--header 'Content-Type: application/json' \
-d '{
"query": {
"bool": {
"must": [
{
"term": {
"id": "609a4797e4b0e5cf9f008de9"
}
}
]
}
}
}'
```
 
12.索引新增字段
 
```
curl --location --request PUT 'http://172.30.1.12:9200/textmessage/_mapping/doc' \
--header 'Content-Type: application/json' \
--data-raw '{
"properties":{
"replymsgId": {
"index": true,
"store": true,
"type": "keyword"
},
"replyRootMsgId": {
"index": true,
"store": true,
"type": "keyword"
}
}
}'
```
 
13.查看索引模板
 
```
curl --location --request GET 'http://192.168.22.92:9200/_template'
```
posted @ 2022-06-24 16:06  鲤鱼洲畔  阅读(22)  评论(0编辑  收藏  举报