Elasticsearch动态模板匹配几个确切的字段

weixin_38058748 2019-09-12 03:14:59

我目前正在努力简化Elasticsearch的映射模板文件。事实上,我有几个Object字段具有相同的结构(例如源和目标) 有没有办法设置动态模板,以便它可以匹配多个模式? 这是我执行: POST /_template/mapping-lol { "template": "*-newevents-*", "mappings": { "log": { "dynamic_templates": [ { "system": { "match_pattern": "regex", "match": "^(source|destination)$", "mapping": { "properties": { "name": { "dynamic": false, "type": "object", "properties": { "first": { "type": "text" }, "last": { "type": "text" } } }, "ip": { "type": "ip" } } } } } ], "properties": { "source": { "type": "object", "dynamic": true }, "destination": { "type": "object", "dynamic": true } } } } } POST /tenant-newevents-1/log { "source": { "name": { "first": "John", "last": "Doe" }, "ip": "1.2.3.4" }, "destination": { "name": { "first": "Jane", "last": "Doe" }, "ip": "3.4.5.6" } } GET /tenant-newevents-1 这上面没有工作... 我有的是这些相同的方案来匹配(〜20)。 非常感谢您的帮助!








...全文
195 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38079044 2019-09-12
  • 打赏
  • 举报
回复

OK我发现出了什么问题:字段不能映射在所有动态映射继续。在映射工作中删除“源”和“目标”方案。 POST /_template/mapping-lol { "template": "*-newevents-*", "mappings": { "log": { "dynamic_templates": [ { "system": { "match_pattern": "regex", "match": "^(source|destination)$", "mapping": { "properties": { "name": { "dynamic": false, "type": "object", "properties": { "first": { "type": "text" }, "last": { "type": "text" } } }, "ip": { "type": "ip" } } } } } ], "properties": {} } } }

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧