【发布时间】:2022-04-15 01:02:16
【问题描述】:
我正在尝试覆盖一个字段的映射。
有一个默认索引模板(我无法更改),我用自定义模板覆盖它。
默认索引将“消息”字段映射为文本,但我需要将其视为对象并使其字段可索引/可搜索。
这是默认的索引模板,顺序为 10。
{
"mappings": {
"_default_": {
"dynamic_templates": [
{
"message_field": {
"mapping": {
"index": true,
"norms": false,
"type": "text"
},
"match": "message",
"match_mapping_type": "string"
}
},
...
],
"properties": {
"message": {
"doc_values": false,
"index": true,
"norms": false,
"type": "text"
},
...
}
}
},
"order": 10,
"template": "project.*"
}
这是我的覆盖:
{
"template" : "project.*",
"order" : 100,
"dynamic_templates": [
{
"message_field": {
"mapping": {
"type": "object"
},
"match": "message"
}
}
],
"mappings": {
"message": {
"enabled": true,
"properties": {
"tag": {"type": "string", "index": "not_analyzed"},
"requestId": {"type": "integer"},
...
}
}
}
}
这很好用,但我最终在“消息”对象中定义了所有字段(标签、requestId、...)。
有没有办法让“消息”对象中的所有字段都可索引/可搜索?
这是一个示例文档:
{
"level": "30",
...
"kubernetes": {
"container_name": "data-sync-server",
"namespace_name": "alitest03",
...
},
"message": {
"tag": "AUDIT",
"requestId": 1234,
...
},
}
...
}
尝试了很多东西,但我无法成功。
我使用的是 ElasticSearch 2.4.4 版。
【问题讨论】:
标签: elasticsearch