# Approach for determining the structure of the search output of an aggregation from the query

**URL:** <https://discuss.elastic.co/t/approach-for-determining-the-structure-of-the-search-output-of-an-aggregation-from-the-query/212159>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 17, 2019, 12:07pm UTC](https://discuss.elastic.co/t/approach-for-determining-the-structure-of-the-search-output-of-an-aggregation-from-the-query/212159 "2019-12-17T12:07:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sentient-soellingera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sentient-soellingera/32/63782_2.png) [@sentient-soellingera](https://discuss.elastic.co/u/sentient-soellingera)\
**Post date:** [December 17, 2019, 12:07pm UTC](https://discuss.elastic.co/t/approach-for-determining-the-structure-of-the-search-output-of-an-aggregation-from-the-query/212159/1 "2019-12-17T12:07:52Z")

</div>

Hi, I am pretty new to Elasticsearch, so maybe this is a stupid question. First and foremost, I am looking to better understand the link between my aggregation query structure and the return structure. Is there a blog or guide about this? Looking for a way to avoid writing custom parsers for the structure returned by an aggregation query. Extra points if you have something in python already. What I am looking for is similar to what happens in Kibana when the system displays certain data in a predictable manner. Pseudocode of what I am looking for:

```auto
    query = {...}
    data_addresses=analyze(query)
    response=client.search(query)
    data_i_want = []
    for resp in response: 
        tmp = resp
        for key in data_addresses:
            tmp = tmp[key]
        data_i_want.append(tmp)

```

So my question is, what is the logic of `analyze`?

---

<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 14, 2020, 12:16pm UTC](https://discuss.elastic.co/t/approach-for-determining-the-structure-of-the-search-output-of-an-aggregation-from-the-query/212159/2 "2020-01-14T12:16:22Z")

</div>

Closed on January 14, 2020, 12:16pm UTC

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