ES之文档映射
一、索引文档映射关系创建
【PUT】请求:http://127.0.0.1:9200/user-info/_mapping,参数如下
{
"properties" : {
"name" : {
"type" : "text",
"index" : true
},
"sex" : {
"type" : "keyword",
"index" : true
},
"phoneNum" : {
"type" : "keyword",
"index" : false
}
}
}
user-info为提前创建好的索引名称(可以【PUT】请求:http://127.0.0.1:9200/user-info进行索引创建)
index表示该字段可以索引查询
type为字段类型,有多种,可参考 https://blog.csdn.net/ZYC88888/article/details/83059040
返回结果如下
{
"acknowledged": true
}
二、查询索引文档映射关
【GET】请求:http://127.0.0.1:9200/user-info/_mapping
返回结果如下
{
"user-info": {
"mappings": {
"properties": {
"name": {
"type": "text"
},
"phoneNum": {
"type": "keyword",
"index": false
},
"sex": {
"type": "keyword"
}
}
}
}
}