版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42528266/article/details/102798169
简介:手把手教你怎么操作mapping
新增
- 请求
curl -X PUT "localhost: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"
}
}
}
- 响应
{
"acknowledged": true
}
获取
- 请求
curl -X GET "localhost:9200/xdclass/_mapping"
- 响应
{
"nba": {
"mappings": {
"properties": {
"jerse_no": {
"type": "keyword"
},
"name": {
"type": "text"
},
"play_year": {
"type": "keyword"
},
"position": {
"type": "keyword"
},
"team_name": {
"type": "text"
}
}
}
}
}
批量获取
- 请求
curl -X GET "localhost:9200/nba,cba/mapping"
- 响应
{
"nba": {
"mappings": {
"properties": {
"jerse_no": {
"type": "keyword"
},
"name": {
"type": "text"
},
"play_year": {
"type": "keyword"
},
"position": {
"type": "keyword"
},
"team_name": {
"type": "text"
}
}
}
},
"cba": {
"mappings": {}
}
}
获取所有
- 请求(一)
curl -X GET "localhost:9200/_mapping"
- 响应(一)
{
"nba": {
"mappings": {
"properties": {
"jerse_no": {
"type": "keyword"
},
"name": {
"type": "text"
},
"play_year": {
"type": "keyword"
},
"position": {
"type": "keyword"
},
"team_name": {
"type": "text"
}
}
}
},
"cba": {
"mappings": {}
}
}
- 请求(二)
curl -X GET "localhost:9200/_all/_mapping"
- 响应(二)
{
"nba": {
"mappings": {
"properties": {
"jerse_no": {
"type": "keyword"
},
"name": {
"type": "text"
},
"play_year": {
"type": "keyword"
},
"position": {
"type": "keyword"
},
"team_name": {
"type": "text"
}
}
}
},
"cba": {
"mappings": {}
}
}
修改
- 请求
curl -X PUT "localhost: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"
},
"country": {
"type": "keyword"
}
}
}
- 响应
{
"acknowledged": true
}