完整的点路径(任何级别路径),在dynamic_templates中具有path_match

wag*_*oon 6 mapping elasticsearch elasticsearch-mapping elasticsearch-template

我有这个文件

{
    "text_foo": "lorem ipsum",
    "one":{
        "two":{
            "three":{
                "text_bar": "dolor sit amet"
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我想要完成的事情:我需要动态模板,它将匹配以“text_”开头的任何属性示例:

"mappings" : {
    "dynamic_templates":[
    {
            "text":{
                "match": "text_*",
                "path_match": "*.text_*",
                "match_mapping_type": "*",   
                "mapping":{"type":"text","analyzer":"myCustomAnalyzer"}
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

问题一:

"match"和可以"path_match"一起使用吗?(就像我的例子一样)

问题2:

"path_match":"*.text_*"匹配整个路径"one.two.three.text_*"还是仅匹配“one.text_*”?

问题3:

也会"path_match":"*.text_*"匹配 root 属性吗"text_foo"

问题4:

如果唯一的解决方案是使用正则表达式 ( "match_pattern":"regex"),则正则表达式将匹配整个路径"one.two.three.text_bar"还是仅匹配"text_bar"