我们如何在Elasticsearch的查询结果中消除嵌套元素的根结构?

时间:2019-01-08 06:41:57

标签: elasticsearch kibana elastic-stack

如何编写查询以消除以下文档中的嵌套元素“结果”和“行”。

  

{         “ _id”:“ 0048160a463a73faaa6c90f5af027772”,

  "_rev": "1-ff6255309f1b873a4e482310843a8a15",

  "timestamp": 1496275536932.6602,

  "results": {

    "lines": {

      "S1": [

        {

          "needed_key": "foo",

          "not_needed_key": 1

        }

      ],

      "S2": [

        {

          "needed_key": "bar",

          "not_needed_key": 1

        },

        {

          "needed_key": "foo_bar",

          "not_needed_key": 1

        }

      ],

      ...

    }

  },

  "station": "5002270",

  "another_not_needed_key": "something"

}

如何编写Elasticsearch查询以获取上述文档中没有根结构的输出?

下面是我的预期输出。

{
 "_id": "fd298368a7a344b217698677f3f5a07d",
 "timestamp": 1496275536932.6602,
 "station": "5002270",
 "S1": {
     "needed_key": "foo",
     "not_needed_key": 1
    }
}

0 个答案:

没有答案