elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana
我的系统中有一个多日志类型。我想聚合此日志并将其索引到Elasticsearch中。我的最终模式如下elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana,elasticsearch,indexing,lucene,kibana,elasticsearch,Indexing,Lucene,Kibana,我的系统中有一个多日志类型。我想聚合此日志并将其索引到Elasticsearch中。我的最终模式如下 { "id": 1, "name": 2, "history": [ { "login": { "time": "123", "text": "aaa" }, "logout": { "ti
{
"id": 1,
"name": 2,
"history": [
{
"login": {
"time": "123",
"text": "aaa"
},
"logout": {
"time": "124",
"text": "bbb"
}
},
{
"login": {
"time": "125",
"text": "ccc"
},
"logout": {
"time": "126",
"text": "ddd"
}
}
]
}
当我将此架构索引到Elsaticsearch时,我在Kibana(发现选项卡)中得到以下警告
数组中的对象不受很好的支持
但我可以过滤所有字段
- 为什么会出现这种警告李>
- 数组中的对象不支持Elasticsearch李>
- 我该怎么办李>
- 是否有另一种方法对这种模式进行索引
您应该使用嵌套的类型而不是对象 对象数组不能像预期的那样工作:不能独立于数组中的其他对象查询每个对象。如果您需要能够做到这一点,那么您应该使用嵌套数据类型而不是对象数据类型 可以创建动态映射
PUT my_index
{
"mappings": {
"doc": {
"dynamic_templates": [
{
"objects": {
"match_mapping_type": "object",
"mapping": {
"type": "nested"
}
}
}
],
"properties": {
"id": {
"type": "keyword"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
或者您可以创建自己的模式
PUT my_index
{
"mappings": {
"doc": {
"properties": {
"history": {
"type": "nested",
"properties": {
"login": {
"type": "nested",
"properties": {
"text": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"time": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"logout": {
"type": "nested",
"properties": {
"text": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"time": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
},
"id": {
"type": "keyword"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
@Soheyl这有帮助吗?您是否设法使用嵌套数据类型?:|我收到错误“对象映射[历史记录]无法从嵌套更改为非嵌套”您是否先删除了索引?是的。我还创建了一个新的索引!