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

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.

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.

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