Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Indexing_Lucene_Kibana - Fatal编程技术网 elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana,elasticsearch,indexing,lucene,kibana,elasticsearch,Indexing,Lucene,Kibana" /> elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana,elasticsearch,indexing,lucene,kibana,elasticsearch,Indexing,Lucene,Kibana" />

elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana

elasticsearch 获取“;数组中的对象不受很好的支持”;使用Kibana中的新模式Kibana,elasticsearch,indexing,lucene,kibana,elasticsearch,Indexing,Lucene,Kibana,我的系统中有一个多日志类型。我想聚合此日志并将其索引到Elasticsearch中。我的最终模式如下 { "id": 1, "name": 2, "history": [ { "login": { "time": "123", "text": "aaa" }, "logout": { "ti

我的系统中有一个多日志类型。我想聚合此日志并将其索引到Elasticsearch中。我的最终模式如下

{
    "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这有帮助吗?您是否设法使用嵌套数据类型?:|我收到错误“对象映射[历史记录]无法从嵌套更改为非嵌套”您是否先删除了索引?是的。我还创建了一个新的索引!