我正在运行 Elasticsearch 版本 8.8.0,我想将
source.as.organization.name
和 destination.as.organization.name
映射为 keyword
字段。这是使用 Filebeat 发送到 ES 的数据,会自动丰富 IP geoloc。
我的索引映射的相关部分如下。
"source": {
"type": "object",
"properties": {
"as": {
"type": "object",
"properties": {
"number": {
"type": "integer"
},
"organization": {
"properties": {
"name": {
"type": "keyword"
}
}
}
}
},
...
"destination": {
"type": "object",
"properties": {
"as": {
"type": "object",
"properties": {
"number": {
"type": "integer"
},
"organization": {
"properties": {
"name": {
"type": "keyword"
}
}
}
}
},
...
当我检查 Kibana 上的“索引模板”页面时,两个字段的映射都显示为
Keyword
。但是,当我查看记录时,这两个字段仍然显示,旁边带有 t
图标,表明它们是文本字段。
为什么这些字段仍然存储为
text
字段,如何才能将它们存储为 keyword
字段?
索引创建后,您将无法更新字段类型。您可以创建一个新索引来查看您的索引模板是否正常工作。
创建索引后,如果映射看起来正确,您可以使用新索引。
如果您使用的是数据流索引或翻转索引,您可以使用
_rollover
API 调用来创建新索引。翻转后检查最新的数据流索引映射以确保一切正常。如果一切顺利,将旧数据重新索引到最新索引。
翻转或创建与索引模板中的index_pattern匹配的新索引后,如果新的索引映射仍然与索引模板中的索引模式不匹配,则可能存在多个相互
override
的模板。要查看索引在创建过程中使用哪个索引模板,您可以使用 simulate
API 调用。
POST /_index_template/_simulate_index/my-index-000001
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-simulate-index.html