# Output aggregation results using visualization in Kibana

**URL:** <https://discuss.elastic.co/t/output-aggregation-results-using-visualization-in-kibana/159385>\
**Category:** Kibana\
**Created:** [December 4, 2018, 2:46pm UTC](https://discuss.elastic.co/t/output-aggregation-results-using-visualization-in-kibana/159385 "2018-12-04T14:46:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vphant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vphant/32/38233_2.png) [@vphant](https://discuss.elastic.co/u/vphant)\
**Post date:** [December 4, 2018, 2:46pm UTC](https://discuss.elastic.co/t/output-aggregation-results-using-visualization-in-kibana/159385/1 "2018-12-04T14:46:31Z")

</div>

I have such a structure in index `answers`.

```auto
{"can_view": ["F1", "F2", "F3"],"ext_id":20,"alias":"firstname","value":"John"}
{"can_view": ["F1", "F2", "F3"],"ext_id":20,"alias":"lastname","value":"Mullen"}
{"can_view": ["F1", "F2", "F3"],"ext_id":20,"alias":"phone","value":"99877"}
{"can_view": ["F1", "F2"],"ext_id":1,"alias":"firstname","value":"Janelle"}
{"can_view": ["F1"],"ext_id":2,"alias":"phone","value":"222555"}

```

I can make such a request.

```auto
GET /answers/_search?pretty
{
    "size": 0,
    "aggs" : {
        "alias_group" : {
            "terms" : { "field" : "ext_id"},
            "aggs": {
                "bucket_items": {
                    "top_hits": {
                        "_source": {
                            "includes": ["ext_id", "alias", "value", "can_view"]
                        },
                        "size": 100
                    }
                }
            }
        }
    }
}

```

And I get such a result:

```auto
{
  "took" : 7,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 5,
    "max_score" : 0.0,
    "hits" : []
  },
  "aggregations" : {
    "alias_group" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : 20,
          "doc_count" : 3,
          "bucket_items" : {
            "hits" : {
              "total" : 3,
              "max_score" : 1.0,
              "hits" : [
                {
                  "_index" : "answers",
                  "_type" : "_doc",
                  "_id" : "2",
                  "_score" : 1.0,
                  "_source" : {
                    "can_view" : [
                      "F1",
                      "F2",
                      "F3"
                    ],
                    "ext_id" : 20,
                    "alias" : "lastname",
                    "value" : "Mullen"
                  }
                },
                {
                  "_index" : "answers",
                  "_type" : "_doc",
                  "_id" : "1",
                  "_score" : 1.0,
                  "_source" : {
                    "can_view" : [
                      "F1",
                      "F2",
                      "F3"
                    ],
                    "ext_id" : 20,
                    "alias" : "firstname",
                    "value" : "John"
                  }
                },
                {
                  "_index" : "answers",
                  "_type" : "_doc",
                  "_id" : "3",
                  "_score" : 1.0,
                  "_source" : {
                    "can_view" : [
                      "F1",
                      "F2",
                      "F3"
                    ],
                    "ext_id" : 20,
                    "alias" : "phone",
                    "value" : "99877"
                  }
                }
              ]
            }
          }
        },
        {
          "key" : 1,
          "doc_count" : 1,
          "bucket_items" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                {
                  "_index" : "answers",
                  "_type" : "_doc",
                  "_id" : "4",
                  "_score" : 1.0,
                  "_source" : {
                    "can_view" : [
                      "F1",
                      "F2"
                    ],
                    "ext_id" : 1,
                    "alias" : "firstname",
                    "value" : "Janelle"
                  }
                }
              ]
            }
          }
        },
        {
          "key" : 2,
          "doc_count" : 1,
          "bucket_items" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                {
                  "_index" : "answers",
                  "_type" : "_doc",
                  "_id" : "5",
                  "_score" : 1.0,
                  "_source" : {
                    "can_view" : [
                      "F1"
                    ],
                    "ext_id" : 2,
                    "alias" : "phone",
                    "value" : "222555"
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

```

So I get several buckets for each ext\_id.  
Now I want to make something similar in a DataTable using Kibana visualization.  
So I add such a metric:

```auto
Metrics:
Metric:
Aggregation: Top Hit
Field: value.keyword
Aggregate with: Concatenate
Size: 25
Sort On: _id
Order: Ascending

Buckets:
Split Rows:
Aggregation: Terms
Field: ext_id
Order By: Alphabetical
Order: Ascending
Size: 50

Split Rows:
Aggregation: Terms
Field: alias.keyword
Order By: Alphabetical
Order: Ascending
Size: 50

```

I get a result:  
[See screenshot]

 ![dataTable](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a014cf1ab4f47b10484736dff59bb634c6f10ca6.png)

This is not exactly what I want to get.  
I want to get such an output:

```auto
ext_id.....firstname.....lastname.....phone.
1..........Janelle.......--------......---..
2..........---------.....--------.....222555
20.........John..........Mullen.......99877

```

Is there a way to make such a visualization in kibana? What metricks/buckets/filters should I use?  
Thanks.

_Versions that I use are:_

_elasticsearch 6.5.1_  
_kibana 6.5.1_  
_X-Pack_

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 1, 2019, 2:46pm UTC](https://discuss.elastic.co/t/output-aggregation-results-using-visualization-in-kibana/159385/2 "2019-01-01T14:46:32Z")

</div>

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