本篇記錄的全部是索引的相關操作
###
**新增**
###
命令:`curl -X PUT "http://10.10.16.180:9200/nba" | json_pp`
###
結果:
###
```
gold@1498775ba8fe ~ % curl -X PUT "http://10.10.16.180:9200/nba" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 62 100 62 0 0 103 0 --:--:-- --:--:-- --:--:-- 104
{
"acknowledged" : true,
"index" : "nba",
"shards_acknowledged" : true
}
```
###
**獲取**
###
命令:`curl -X GET "http://10.10.16.180:9200/nba" | json_pp`
###
結果:
###
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/nba" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 225 100 225 0 0 9083 0 --:--:-- --:--:-- --:--:-- 12500
{
"nba" : {
"aliases" : {},
"mappings" : {},
"settings" : {
"index" : {
"creation_date" : "1694227082539",
"number_of_replicas" : "1",
"number_of_shards" : "1",
"provided_name" : "nba",
"uuid" : "8CLIFy9eS2qZcm-k3kFBpg",
"version" : {
"created" : "7020099"
}
}
}
}
}
```
###
**刪除**
###
命令:`curl -X DELETE "http://10.10.16.180:9200/nba" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X DELETE "http://10.10.16.180:9200/nba" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21 100 21 0 0 153 0 --:--:-- --:--:-- --:--:-- 160
{
"acknowledged" : true
}
```
###
**批量獲取**
###
命令:`curl -X GET "http://10.10.16.180:9200/nba,cba" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/nba,cba" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 449 100 449 0 0 19445 0 --:--:-- --:--:-- --:--:-- 26411
{
"cba" : {
"aliases" : {},
"mappings" : {},
"settings" : {
"index" : {
"creation_date" : "1694227737478",
"number_of_replicas" : "1",
"number_of_shards" : "1",
"provided_name" : "cba",
"uuid" : "Nhv8vckSSSKR7LcenSPVDA",
"version" : {
"created" : "7020099"
}
}
}
},
"nba" : {
"aliases" : {},
"mappings" : {},
"settings" : {
"index" : {
"creation_date" : "1694227698390",
"number_of_replicas" : "1",
"number_of_shards" : "1",
"provided_name" : "nba",
"uuid" : "M6rRM4xFST64Nl24x51ZQg",
"version" : {
"created" : "7020099"
}
}
}
}
}
```
###
**獲取所有**
###
命令:`curl -X GET "http://10.10.16.180:9200/_all" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/_all" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 449 100 449 0 0 18398 0 --:--:-- --:--:-- --:--:-- 24944
{
"cba" : {
"aliases" : {},
"mappings" : {},
"settings" : {
"index" : {
"creation_date" : "1694227737478",
"number_of_replicas" : "1",
"number_of_shards" : "1",
"provided_name" : "cba",
"uuid" : "Nhv8vckSSSKR7LcenSPVDA",
"version" : {
"created" : "7020099"
}
}
}
},
"nba" : {
"aliases" : {},
"mappings" : {},
"settings" : {
"index" : {
"creation_date" : "1694227698390",
"number_of_replicas" : "1",
"number_of_shards" : "1",
"provided_name" : "nba",
"uuid" : "M6rRM4xFST64Nl24x51ZQg",
"version" : {
"created" : "7020099"
}
}
}
}
}
```
###
**獲取es節點情況**
###
命令:`curl -X GET "http://10.10.16.180:9200/_cat/indices?v"`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open nba M6rRM4xFST64Nl24x51ZQg 1 1 0 0 230b 230b
yellow open cba Nhv8vckSSSKR7LcenSPVDA 1 1 0 0 230b 230b
```
###
返回的參數具體含義如下:
> * `health`: 索引的健康狀態,可以是以下幾種狀態之一:
> * `green`: 所有主分片和副本分片都正常。
> * `yellow`: 所有主分片都正常,但是至少有一個副本分片丟失。
> * `red`: 至少有一個主分片丟失,索引無法正常工作。
> * `status`: 索引的狀態,通常為`open`,表示索引是打開的并可用。
> * `index`: 索引的名稱。
> * `uuid`: 索引的唯一標識符。
> * `pri`: 索引的主分片數量。
> * `rep`: 索引的副本分片數量。
> * `docs.count`: 索引中的文檔數量。
> * `docs.deleted`: 被標記為刪除的文檔數量。
> * `store.size`: 索引在磁盤上的總存儲大小。
> * `pri.store.size`: 主分片在磁盤上的存儲大小。
>
> 在給定的結果中,有兩個索引被列出:`nba`和`cba`。它們都處于黃色狀態,意味著它們的主分片和副本分片數量均為1,并且當前沒有文檔。存儲大小為230字節,主分片的存儲大小也是230字節。
###
判斷索引是否存在
###
命令:`curl -I "http://10.10.16.180:9200/nba" `
###
結果:
```
gold@1498775ba8fe ~ % curl -I "http://10.10.16.180:9200/nba"
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 225
```
###
**關閉**
###
命令:`curl -X POST "http://10.10.16.180:9200/nba/_close" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X POST "http://10.10.16.180:9200/nba/_close" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48 100 48 0 0 180 0 --:--:-- --:--:-- --:--:-- 184
{
"acknowledged" : true,
"shards_acknowledged" : true
}
```
###
**打開**
###
命令:`curl -X POST "http://10.10.16.180:9200/nba/_open" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X POST "http://10.10.16.180:9200/nba/_open" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48 100 48 0 0 111 0 --:--:-- --:--:-- --:--:-- 113
{
"acknowledged" : true,
"shards_acknowledged" : true
}
```
###
- 基礎概念
- 為什么不使用mysql做全文搜索
- 常見的搜索引擎
- 快速安裝部署es
- 補充ES和kibana認證
- 補充kibana中文顯示
- ES的目錄以及核心概念介紹
- RESTful風格介紹
- 索引的各類操作
- 映射的各類操作
- 文檔的各類操作
- 搜索的使用
- 中文分詞器
- 常見字段類型
- kibana的安裝
- es批量導入數據
- es的term的多種查詢
- es的范圍查詢
- es的布爾查詢
- es的排序查詢
- es的指標聚合查詢
- es的桶聚合查詢
- es的別名操作
- es重建索引
- es的refresh操作
- es的高亮查詢
- es的查詢建議
- java實操es之集成
- 補充java操作es集成認證
- 補充java連接es集群
- java實操es之準備工作
- java實操es之各種騷操作(一期)
- java實戰之數據庫文件
- java實操es之各種騷操作(二期)
- java實操es之各種騷操作(三期)
- es分布式集群概念介紹
- es分布式集群的搭建
- es分布式集群kibana的配置
- es分布式集群分片管理
- es分布式集群節點健康管理
- es故障排查總結