主要讲mapping,定义结构。
1.新增
PUT /nba/_mapping
{
"properties": {
"name": {
"type": "text"
},
"team_name": {
"type": "text"
},
"position": {
"type": "keyword"
},
"play_year": {
"type": "keyword"
},
"jerse_no": {
"type": "keyword"
}
}
}
結果:
{
"acknowledged" : true
}
2.獲取
GET /nba/_mapping
结果:
{
"nba" : {
"mappings" : {
"properties" : {
"jerse_no" : {
"type" : "keyword"
},
"name" : {
"type" : "text"
},
"play_year" : {
"type" : "keyword"
},
"position" : {
"type" : "keyword"
},
"team_name" : {
"type" : "text"
}
}
}
}
}
3.批量获取
GET /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" : { }
}
}
4.获取所有
GET /_mapping GET /_all/_mapping
5.修改
在下面添加一个新的字段。注意点,字段的类型不能修改。
POST /nba/_mapping
{
"properties": {
"name": {
"type": "text"
},
"team_name": {
"type": "text"
},
"position": {
"type": "keyword"
},
"play_year": {
"type": "keyword"
},
"jerse_no": {
"type": "keyword"
},
"contry":{
"type": "keyword"
}
}
}
结果:
{
"acknowledged" : true
}