Make Array of objects as type nested

I am using JDBC-input and pulling data from Postgres. My input statement looks like

statement => "select a.id, a.deleted_at, a.updated_at, json_agg(b.*)::text as user_hubs, json_agg(c.*)::text as user_schools, json_agg(d.*)::text as user_clusters
      from users a
      left join user_hubs b on a.id = b.user_id
      left join user_schools c on a.id = c.user_id
      left join user_clusters d on a.id = d.user_id
      group by a.id
      limit 20"

I have a filter which helps me parse JSON

filter {
  json {
    source => "user_hubs"
    target => "user_hubs"
  }
  json {
    source => "user_clusters"
    target => "user_clusters"
  }
}

I get an output as

{
  "deleted_at": "2018-01-16T17:18:13.000Z",
  "user_hubs": [
      {
          "message": null,
          ...
      }
  ],
  "updated_at": "2018-01-16T17:18:13.000Z",
  "@timestamp": "2019-05-24T10:59:42.363Z",
  "id": 11014,
  "user_clusters": [
      {
          "deleted_at": "2018-01-16T22:48:13+05:30",
          "full_unsubscribed": false,
          ...
      }
  ],
  "user_schools": [
      null
  ],
  "@version": "1"
}

I want user_clusters and user_hubs to be nested object type. what I am missing ??

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.