# Convert a search JSON into a DSL query

**URL:** <https://discuss.elastic.co/t/convert-a-search-json-into-a-dsl-query/303156>\
**Category:** Kibana\
**Created:** [April 25, 2022, 11:44am UTC](https://discuss.elastic.co/t/convert-a-search-json-into-a-dsl-query/303156 "2022-04-25T11:44:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelvins](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kelvins](https://discuss.elastic.co/u/kelvins)\
**Post date:** [April 25, 2022, 11:44am UTC](https://discuss.elastic.co/t/convert-a-search-json-into-a-dsl-query/303156/1 "2022-04-25T11:44:25Z")

</div>

I have created the following search query in Elastic. I am wanting to using it in a Discover query using the _Elasticsearch Query DSL_. However, I cannot seem to convert it. This is the query that I have using Kibana Dev console:

```auto
GET testssl*/_search
{
  "aggs": {
    "2": {
      "terms": {
        "field": "identifierTupple",
        "order": {
          "_key": "desc"
        },
        "size": 120
      },
      "aggs": {
        "1": {
          "top_hits": {
            "size": 1,
            "sort": [
              {
                "timestamp": {
                  "order": "desc"
                }
              }
            ]
          }
        }
      }
    }
  },
  "size": 0
}

```

I cannot seem to convert the above to elastic DSL to use. Is this possible?

My outcome is to create a discover view showing the top hits of `identifierTupple`.

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [April 26, 2022, 9:19am UTC](https://discuss.elastic.co/t/convert-a-search-json-into-a-dsl-query/303156/2 "2022-04-26T09:19:22Z")

</div>

Hi

We are currently not supporting aggregation in Discover, but we are working on making this possible in the future. Here is an older issue for that:

> <https://github.com/elastic/kibana/issues/29726>
>
> \*\*Describe the feature:\*\*
> I would love to see the ability to perform aggregatio…ns on the Discovery App.
> 
> \*\*Describe a specific use case for the feature:\*\*
> Currently when I want to see the source / destination traffic I need to create a graph or table (Of course I have a dashboard for this, but just as an example). I would like to be able to choose to aggregate the results on the Discover App so that I can quickly find what I need and be able to filter based on the aggregated results to continue my quest in finding the right events that I am searching for.

Best,  
Matthias

---

<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:** [May 24, 2022, 9:19am UTC](https://discuss.elastic.co/t/convert-a-search-json-into-a-dsl-query/303156/3 "2022-05-24T09:19:55Z")

</div>

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