自动映射有三种模式:
true : 遇到陌生字段,就进行dynamic mapping
false : 遇到陌生字段,就忽略
strict : 遇到陌生字段,就报错
PUT my_index/_mapping/my_type
{
"dynamic":true
}
//查看 在"properties" 上面会多出一行配置,"dynamic" : "true",
GET my_index/_mapping/my_type
注意:字段默认为text类型 ,聚合时需要进一步设置 fielddata 或者 字段用 "字段.keyword代替"
POST my_index/my_type
{
"properties":{
"tag":{
"type":"text",
"fielddata":true
}
}
}