我知道我可以dynamic_template用来not_analyzed为特定新索引中的新字段设置字符串字段.
有没有办法全局应用此设置- 即为not_analyzed任何新索引中的任何字符串字段设置属性?(无需为每个新索引设置它)
是的,你可以通过创建一个实现这个指标模板上*有一个_default_映射类型和动态模板
curl -XPUT localhost:9200/_template/global -d '{
"template": "*",
"mappings": {
"_default_": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "string",
"index": "not_analyzed"
}
}
}
]
}
}
}'
Run Code Online (Sandbox Code Playgroud)
然后,您可以在任何新索引中创建任何文档,并且所有字符串字段都将是 not_analyzed
curl -XPUT localhost:9200/dummy_index/dummy_type/1 -d '{"name": "dummy"}'
Run Code Online (Sandbox Code Playgroud)
如果检查dummy_type新创建的映射类型dummy_index,您将看到该name字段将是not_analyzed
| 归档时间: |
|
| 查看次数: |
1996 次 |
| 最近记录: |