本篇記錄的全部是映射相關的操作:
###
**新增**
###
命令:
###
```
curl -X PUT "http://10.10.16.180:9200/nba/_mapping" -H 'Content-Type: application/json' -d'
{
"properties": {
"name": {
"type": "text"
},
"team_name": {
"type": "text"
},
"position": {
"type": "keyword"
},
"play_year": {
"type": "keyword"
},
"jerse_no": {
"type": "keyword"
}
}
}
' | json_pp
```
###
結果
###
```
{
"acknowledged" : true
}
```
###
**獲取**
###
命令:`curl -X GET "http://10.10.16.180:9200/nba/_mapping" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/nba/_mapping" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 179 100 179 0 0 6618 0 --:--:-- --:--:-- --:--:-- 8950
{
"nba" : {
"mappings" : {
"properties" : {
"jerse_no" : {
"type" : "keyword"
},
"name" : {
"type" : "text"
},
"play_year" : {
"type" : "keyword"
},
"position" : {
"type" : "keyword"
},
"team_name" : {
"type" : "text"
}
}
}
}
}
```
###
**批量獲取**
###
命令:`curl -X GET "http://10.10.16.180:9200/nba,cba/_mapping" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/nba,cba/_mapping" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 201 100 201 0 0 8355 0 --:--:-- --:--:-- --:--:-- 11166
{
"cba" : {
"mappings" : {}
},
"nba" : {
"mappings" : {
"properties" : {
"jerse_no" : {
"type" : "keyword"
},
"name" : {
"type" : "text"
},
"play_year" : {
"type" : "keyword"
},
"position" : {
"type" : "keyword"
},
"team_name" : {
"type" : "text"
}
}
}
}
}
```
###
**獲取所有的索引的映射(方式一)**
###
命令:`curl -X GET "http://10.10.16.180:9200/_mapping" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/_mapping" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 201 100 201 0 0 12692 0 --:--:-- --:--:-- --:--:-- 20100
{
"cba" : {
"mappings" : {}
},
"nba" : {
"mappings" : {
"properties" : {
"jerse_no" : {
"type" : "keyword"
},
"name" : {
"type" : "text"
},
"play_year" : {
"type" : "keyword"
},
"position" : {
"type" : "keyword"
},
"team_name" : {
"type" : "text"
}
}
}
}
}
```
###
**獲取所有的索引的映射(方式二)**
###
命令:`curl -X GET "http://10.10.16.180:9200/_all/_mapping" | json_pp`
###
結果:
```
gold@1498775ba8fe ~ % curl -X GET "http://10.10.16.180:9200/_all/_mapping" | json_pp
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 201 100 201 0 0 8011 0 --:--:-- --:--:-- --:--:-- 11166
{
"cba" : {
"mappings" : {}
},
"nba" : {
"mappings" : {
"properties" : {
"jerse_no" : {
"type" : "keyword"
},
"name" : {
"type" : "text"
},
"play_year" : {
"type" : "keyword"
},
"position" : {
"type" : "keyword"
},
"team_name" : {
"type" : "text"
}
}
}
}
}
```
###
**修改**
###
命令:
```
curl -X PUT "http://10.10.16.180:9200/nba/_mapping" -H 'Content-Type: application/json' -d'
{
"properties": {
"Uname": {
"type": "text"
}
}
}'
```
###
結果:
```
{"acknowledged":true}
```
###
Uname在mapping當中從來沒存在過 實際上是在原有的基礎上新增了Uname字段
###

###
- 基礎概念
- 為什么不使用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故障排查總結