我可以使用通配符模式来确定Elasticsearch的索引分析器吗?
例如:
“属性”:
{
"0_*" : {"type": "string", "index_analyzer": "standard" } ,
"1_*" : {"type": "string", "index_analyzer": "my_analyzer"}
}
所以现在在索引文件时,如果有一个新字段
{
"0_title" : "some string", // should use standard analyzer
"1_title" : "my anazlyer string" // should use my_analyzer
}
反正有实现这个目标的方法吗?
最佳答案
是的,您需要使用的只是索引模板。
您可以找到有关动态模板here的更多信息
使用索引模板,您可以按如下方式插入规则-
{
"person": {
"dynamic_templates": [
{
"template_0": {
"match": "0_*",
"mapping": {
"type": "string",
"index_analyzer": "standard"
}
}
},
{
"template_1": {
"match": "1_*",
"mapping": {
"type": "string",
"index_analyzer": "my_analyzer"
}
}
}
]
}
}
关于elasticsearch - 基于字段的动态映射Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27901485/