{
"mappings" : {
"post" : {
"_analyzer" : {
"path" : "language"
},
"properties" : {
"id": { "type" : "long", "store" : "yes",
"precision_step" : "0" },
"name": { "type" : "string", "store" : "yes",
"index" : "analyzed" },
"language": { "type" : "string", "store" : "yes",
"index" : "not_analyzed"}
}
}
}
}
_analyzer 的path指定文档中某个字段名,比如上面,指定language,则说明文档使用的分析器为 文档中language 的值。
假设你有两个分析器 english 和 chinese。不同的文档,你想要使用不同的分析器,文档1全是中文,你就使用chinese分析器,文档2中全是英文,你就使用english分析器,那么你就可以这样配置。