对 Elasticsearch 索引模板中以相同名称开头的所有字段应用相同的设置
在我的elasticsearch索引中,有一个字段例如field_abc,它是一个对象。问题是多个名为 field_abc 的字段可以存在,但具有不同的后缀。就像我们在同一个文档的索引中field_abc_1、field_abc_2、field_abc_3都可以存在。此类字段的数量不固定,并且在多个文档中可以不同。这些字段内的对象的结构是相同的。现在,在该索引的模板设置中,如何确保在每个此类字段上应用相同的设置?例如,现在在我的索引模板中,我对 field_abc 有以下设置
"field_abc": {
"properties": {
"item": {"type": "keyword"},
"data": {"type": "keyword"},
"description": {"type": "keyword"},
"flag": {"type": "boolean"}
}
}
正如上面所讨论的,我的文档中有多个以名称 field_abc 开头的此类字段,并且此类字段的数量不固定。所以我想问,如何为索引中以名称 field_abc 开头的所有字段拥有动态且相同的设置?请在这方面指导我。
In my elasticsearch index, there is a field for example field_abc that is an object. The problem is that multiple fields with name field_abc can exist with different suffix. Like in our index in the same document field_abc_1, field_abc_2, field_abc_3 can exist. The number of such fields is not fixed and can be different in multiple documents. The structure of the object inside these fields is the same. Now in my template settings of this index, how can I make sure that same settings are applied on each such field? For example, in my index template right now I have following settings for the field_abc
"field_abc": {
"properties": {
"item": {"type": "keyword"},
"data": {"type": "keyword"},
"description": {"type": "keyword"},
"flag": {"type": "boolean"}
}
}
As I have discussed above, I have multiple such fields that start with name field_abc in my document and the number of such fields is not fixed. So I want to ask that how can I have a dynamic and same settings for all those fields in my index that start with the name field_abc? Kindly guide me in this regard.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在索引映射中启用
"dynamic":"true"
,然后添加 动态映射,匹配通配符字段名称 (field_abc_*
) 以设置类型。您可以根据字段名称、完整字段路径或字段类型进行匹配。You can enable
"dynamic":"true"
in the index mapping, and then add a dynamic mapping that matches a wildcard field name (field_abc_*
) to set the type. You can match based on the field name, the complete field path, or the field type.