# What is difference between POST and GET in aggregation request?

**URL:** <https://discuss.elastic.co/t/what-is-difference-between-post-and-get-in-aggregation-request/162432>\
**Category:** Elasticsearch\
**Created:** [December 30, 2018, 2:03am UTC](https://discuss.elastic.co/t/what-is-difference-between-post-and-get-in-aggregation-request/162432 "2018-12-30T02:03:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [December 30, 2018, 2:03am UTC](https://discuss.elastic.co/t/what-is-difference-between-post-and-get-in-aggregation-request/162432/1 "2018-12-30T02:03:49Z")

</div>

Hi, I am studying aggregation part.

Some aggregation examples are using POST request type and others are using GET request type.

Both of them show me the same result.

Is it ok to use any one of them or there is reason to difference.

```
POST /exams/_search?size=0
{
    "aggs" : {
    "avg_grade" : { "avg" : { "field" : "grade" } }
    }
}

GET emails/_search
{
    "size": 0,
    "aggs" : {
        "interactions" : {
           "adjacency_matrix" : {
                "filters" : {
                    "grpA" : { "terms" : { "accounts" : ["hillary", "sidney"] }},
                    "grpB" : { "terms" : { "accounts" : ["donald", "mitt"] }},
                    "grpC" : { "terms" : { "accounts" : ["vladimir", "nigel"] }}
                 }
            }
        }
    }
}

```

Thanks,  
HJ SHIN.

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [December 30, 2018, 2:52am UTC](https://discuss.elastic.co/t/what-is-difference-between-post-and-get-in-aggregation-request/162432/2 "2018-12-30T02:52:20Z")

</div>

It's the same thing — no difference. For regular search queries it's the same BTW.

Conceptually `GET` might make more sense, since you are just fetching data and it's an idempotent command. However, `GET` doesn't have a body and some clients (like browser plugins) might simply not send the body if you are doing a `GET`. So `POST` is an alternative, which has a body, but is maybe not the right HTTP verb for fetching data.

Generally we are trying to stick to REST conventions where possible, but we will also pick pragmatic alternatives if required.

---

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [December 30, 2018, 3:06am UTC](https://discuss.elastic.co/t/what-is-difference-between-post-and-get-in-aggregation-request/162432/3 "2018-12-30T03:06:54Z")

</div>

Your answer helped me to understand!  
Thanks.

---

<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 27, 2019, 3:07am UTC](https://discuss.elastic.co/t/what-is-difference-between-post-and-get-in-aggregation-request/162432/4 "2019-01-27T03:07:01Z")

</div>

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