一,数据类型
1,简单类型
2,复杂类型
3,特殊类型
二,dynamic mapping
创建索引时根据字段内容动态创建mapping结构
1,创建一个索引
POST skus/_doc/1
{
"name":"冰箱"
}
2,修改dynamic为strict,新增字段会报错
PUT skus/_mapping
{
"dynamic":"strict"
}
3,修改dynamic为,新增字段不报错,但不会被查询到
PUT skus/_mapping
{
"dynamic":"false"
}
三,自定义mapping
1,index : false,改字段不会查询到,不会建索引
2,copy_to,代替_all,将多个字段值合并为一个值
3,null_value,指定值为null时的代替值
PUT student
{
"mappings":{
"properties":{
"firstName":{
"type":"text",
"copy_to": "fullName",
"null_value": "NAN"
},
"lastName":{
"type":"text",
"copy_to": "fullName"
},
"age":{
"type":"binary",
"index": false
}
}
}
}
POST student/_doc/1
{
"firstName":"yong",
"lastName":"lu",
"age":1
}
GET student/_search?q=fullName:(yong lu)
四,新增字段
PUT users/_mapping
{
"properties": {
"driverNo": {
"type":"text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
GET users/_mapping