- type:
text可分词 - type:
keyword不可分词
创建Mapping PUT请求
- 请求
localhost:9200/nba/_mapping
- 请求体
{
"properties":{ //字段的信息
"name":{
"type":"text"
},
"team_name":{
"type":"text"
},
"position":{
"type":"keyword"
},
"play_year":{
"type":"keyword"
},
"jerse_no":{
"type":"keyword"
}
}
}
- 响应
{
"acknowledged": true
}
查看Mapping信息 GET请求
- 请求
localhost:9200/nba/_mapping
- 响应
{
"nba": {
"mappings": {
"properties": {
"jerse_no": {
"type": "keyword"
},
"name": {
"type": "text"
},
"play_year": {
"type": "keyword"
},
"position": {
"type": "keyword"
},
"team_name": {
"type": "text"
}
}
}
}
}
批量获取Mapping信息 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": {}
}
}
获取所有Mapping信息第一种方式 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": {}
}
}
获取所有Mapping信息第二种方式 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": {}
}
}
增加Mapping字段 POST请求
Mapping 只可增加字段不可修改字段
- 请求
localhost:9200/nba/_mapping
- 请求体
{
"properties":{
"name":{
"type":"text"
},
"team_name":{
"type":"text"
},
"position":{
"type":"keyword"
},
"play_year":{
"type":"keyword"
},
"jerse_no":{
"type":"keyword"
},
"country":{ // 增加的国家字段
"type":"keyword"
}
}
}
- 响应
{
"acknowledged": true
}