# How to use DSL query from Kibana dev-tools in visualisation?

**URL:** <https://discuss.elastic.co/t/how-to-use-dsl-query-from-kibana-dev-tools-in-visualisation/187846>\
**Category:** Kibana\
**Created:** [June 27, 2019, 1:35pm UTC](https://discuss.elastic.co/t/how-to-use-dsl-query-from-kibana-dev-tools-in-visualisation/187846 "2019-06-27T13:35:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shafeequeaslam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shafeequeaslam/32/48940_2.png) [@shafeequeaslam](https://discuss.elastic.co/u/shafeequeaslam)\
**Post date:** [June 27, 2019, 1:35pm UTC](https://discuss.elastic.co/t/how-to-use-dsl-query-from-kibana-dev-tools-in-visualisation/187846/1 "2019-06-27T13:35:09Z")

</div>

I have successfully aggregated and queried a particular content I needed in Kibana Dev Tools. However, I need this information in a tabular form either as CSV or PDF. For this, I need to run the DSL query I constructed in Dev Tools in visualisation tool of Kibana. However, I am not able to do it.

I tried copying the DSL to the Lucene query text box on the top part of the visualisation page and also tried within the add filter option. Both way it returns an error.

The query that works in Dev Tools:  
```  
{

````
  "query": {
    "bool": {
       "must": [
        { "match": { "start_datetime":"1569868200" }}
      ]
    }
  },
  "aggs" : {
        "state_location" : {
            "terms": {
                "field" : "state_location"
            },
            "aggs": {
                "stakeholder_category": {
                    "terms": {
                        "field": "stakeholder_category"
                    },
                    "aggs": {
                        "coverage_category": {
                            "terms": {
                            "field": "category_paragraph_name.keyword"
                            }
                        }
                    }
                }
            }
        }
    }
}
```

````

Expecting to get the result on visualisation screen as a table, so that I can export it to CSV or PDF.

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [July 25, 2019, 9:41am UTC](https://discuss.elastic.co/t/how-to-use-dsl-query-from-kibana-dev-tools-in-visualisation/187846/2 "2019-07-25T09:41:49Z")

</div>

Hi @shafeequeaslam  
you cannot reuse the same DSL query on a visualization, but you can recreate one:  
in that case seems that it can be achieved with a simple data table visualization. You have just to add 3 `Split row` terms aggregation. That will work and you can visualize the table with your data and also export it as CSV.  
you can add the filter on the start\_datetime using the timepicker if the start\_datetime is the default index-pattern time field, if not you can use a filter for that.

---

<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:** [August 22, 2019, 9:41am UTC](https://discuss.elastic.co/t/how-to-use-dsl-query-from-kibana-dev-tools-in-visualisation/187846/3 "2019-08-22T09:41:50Z")

</div>

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