# Kibana - Visualize - create table from search query

**URL:** <https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861>\
**Category:** Kibana\
**Created:** [March 8, 2017, 5:34pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861 "2017-03-08T17:34:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exocomp](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Exocomp](https://discuss.elastic.co/u/Exocomp)\
**Post date:** [March 8, 2017, 5:34pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861/1 "2017-03-08T17:34:22Z")

</div>

Hi,

I used the Dev Tools tab in Kibana to create a search query (a bit complex using 3 aggregations) and would like to use that query with the Visualize tab to create a table, is that possible ?

Thanks,  
E

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [March 8, 2017, 7:00pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861/2 "2017-03-08T19:00:15Z")

</div>

Hi,

It's not possible to use the search query from dev tools to create a table unfortunately. You need to query using visualizations tab. But we do have an option of using JSON input in advanced settings. Perhaps you want to give it a try?

Thanks,  
Bhavya

 ![](https://us1.discourse-cdn.com/elastic/original/3X/b/5/b543d588c5ed49e08cc730b75065f30cd3191130.png)

---

<div class="post-metadata">

**Author:** ![Exocomp](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Exocomp](https://discuss.elastic.co/u/Exocomp)\
**Post date:** [March 8, 2017, 7:27pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861/3 "2017-03-08T19:27:09Z")

</div>

Hi @bhavyarm,

With my query I'm using top\_hits aggregation and max aggregation, any idea if it supports those? What I'm doing is the following:

1. First using terms aggregation on Field1 (essentially grouping by Field1) then later sort by max sub-aggregator
2. Then using top\_hits sub aggregator to sort by Field2 descending and also return source fields like Field2, Field3, Field4
3. Then using max sub-aggregator on field Field2

The result is that I get my data in buckets that are sorted by the fields I want.

Can this or something similar be accomplished with the Visualize feature ?

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [March 22, 2017, 3:07pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861/4 "2017-03-22T15:07:12Z")

</div>

It seems like this would be possible to create without using the Advanced JSON field (just using the visualization selections).

Top Hits is supported in Kibana 5.2 [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html)

I think you should try to build your visualization using the Visualize tab.

If you can't build exactly what you want, you could save a Data Table, and then go to the Saved Objects in Management and modify the query there, but you would be on your own of that breaks. There's no guarantee the Data Table would work after you modify the query that way.

Regards,  
Lee

Sorry, correction: Top Hits is in Elasticsearch 5.2, but not in Kibana until 5.3 which is not released yet. It should be released soon and I'll try to let you know when it is.

---

<div class="post-metadata">

**Author:** ![Exocomp](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Exocomp](https://discuss.elastic.co/u/Exocomp)\
**Post date:** [March 22, 2017, 8:08pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861/5 "2017-03-22T20:08:41Z")

</div>

@LeeDr

Gotcha, thanks for letting me know!

---

<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:** [April 19, 2017, 8:09pm UTC](https://discuss.elastic.co/t/kibana-visualize-create-table-from-search-query/77861/6 "2017-04-19T20:09:07Z")

</div>

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