我试图使用regex
匹配各种id
字段,如collection_id
所以他们没有被分析。
一个简单的正则表达式^.*_id$
无法匹配字段。
{
"_default_": {
"dynamic_templates": [
{
"system_ids": {
"match_mapping_type": "string",
"match_pattern": "regex",
"match": "^.*_id$",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
我在elasticsearch 5.5上测试它。
经过大量的反复试验后,您需要将正则表达式添加到捕获组中。使用^(.*_id)$
作为match
工作。我不知道为什么,但确实如此。