# elasticsearch.exceptions.TransportError: TransportError 503: Data too large

**URL:** <https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116>\
**Category:** Elasticsearch\
**Created:** [April 16, 2018, 7:44am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116 "2018-04-16T07:44:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaibhav\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_kumar/32/29730_2.png) [@Vaibhav\_Kumar](https://discuss.elastic.co/u/Vaibhav_Kumar)\
**Post date:** [April 16, 2018, 7:44am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/1 "2018-04-16T07:44:07Z")

</div>

I'm trying to get the response from ES hitting it from python code but it is showing the below error:

`elasticsearch.exceptions.TransportError: TransportError(503, u'search_phase_execution_exception', u'[request] Data too large, data for [<agg [POSCodeModifier]>] would be [623327280/594.4mb], which is larger than the limit of [623326003/594.4mb]')`

If i hit the same code from kibana i get the results but using python i'm getting this error. I'm using aggregation in my code. if someone can explain if i need to set some properties or how to optimise it?? Below is the structure for request i'm sending and if i set start and end date greater than 5 days it gives me the error, otherwise i'm getting the results

```
unmtchd_ESdata= es.search(index='cstore_new',body={'size' : 0, "aggs": {
    "filtered": {
      "filter": {
        "bool": {
          "must_not": [
            {
              "match": {
                "CSPAccountNo": store_id
              }
            }
          ],
          "must": [
            {
              "range": {
                "ReportDate": {
                  "gte": start_dt,
                  "lte": end_dt
                }
              }
            }
          ]
        }
      }
    ,
    "aggs": {
      "POSCode": {
        "terms": {
          "field": "POSCode",
          "size": 10000
        },
        "aggs": {
          "POSCodeModifier": {
            "terms": {
              "field": "POSCodeModifier",
              "size": 10000
            },
            "aggs": {
              "CSP": {
                "terms": {
                  "field": "CSPAccountNo",
                  "size": 10000
                },
                "aggs": {
                  "per_stock": {
                    "date_histogram": {
                      "field": "ReportDate",
                      "interval": "week",
                      "format": "yyyy-MM-dd",
                      "min_doc_count": 0,
                      "extended_bounds": {
                        "min": start_dt,
                        "max": end_dt
                      }
                    },
                    "aggs": {
                      "avg_week_qty_sales": {
                        "sum": {
                          "field": "TotalCount"
                        }
                      }
                    }
                  },
                  "market_week_metrics": {
                    "extended_stats_bucket": {
                      "buckets_path": "per_stock>avg_week_qty_sales"
                    }
                  }
                }
              }
            }

          }
        }
      }
    }
  }
}},request_timeout=1000)
```

---

<div class="post-metadata">

**Author:** ![NickOver](https://avatars.discourse-cdn.com/v4/letter/n/74df32/32.png) [@NickOver](https://discuss.elastic.co/u/NickOver)\
**Post date:** [April 16, 2018, 7:54am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/2 "2018-04-16T07:54:45Z")

</div>

Can u show us your python code? Without it optimalisation can be hard 🙂

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 16, 2018, 7:58am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/3 "2018-04-16T07:58:41Z")

</div>

Size:10000 is producing too many data.

---

<div class="post-metadata">

**Author:** ![Vaibhav\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_kumar/32/29730_2.png) [@Vaibhav\_Kumar](https://discuss.elastic.co/u/Vaibhav_Kumar)\
**Post date:** [April 16, 2018, 9:06am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/4 "2018-04-16T09:06:10Z")

</div>

so which size i should reduce? i declared it at 3 levels in my request and i hope after reducing the size i have all the relevant data??

---

<div class="post-metadata">

**Author:** ![Vaibhav\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_kumar/32/29730_2.png) [@Vaibhav\_Kumar](https://discuss.elastic.co/u/Vaibhav_Kumar)\
**Post date:** [April 16, 2018, 9:07am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/5 "2018-04-16T09:07:35Z")

</div>

the curl request or kibana hit it self is not working so i don't think you need python code for this

---

<div class="post-metadata">

**Author:** ![NickOver](https://avatars.discourse-cdn.com/v4/letter/n/74df32/32.png) [@NickOver](https://discuss.elastic.co/u/NickOver)\
**Post date:** [April 16, 2018, 9:10am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/6 "2018-04-16T09:10:44Z")

</div>

You are right. I think you generate request in python.

---

<div class="post-metadata">

**Author:** ![Vaibhav\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_kumar/32/29730_2.png) [@Vaibhav\_Kumar](https://discuss.elastic.co/u/Vaibhav_Kumar)\
**Post date:** [April 16, 2018, 9:12am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/7 "2018-04-16T09:12:48Z")

</div>

yes using "from elasticsearch import Elasticsearch".

So any suggestions how i can improve on it??

---

<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 14, 2018, 9:12am UTC](https://discuss.elastic.co/t/elasticsearch-exceptions-transporterror-transporterror-503-data-too-large/128116/8 "2018-05-14T09:12:50Z")

</div>

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