# Elasticsearch aggregation OOM

**URL:** <https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001>\
**Category:** Elasticsearch\
**Created:** [January 9, 2017, 9:38pm UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001 "2017-01-09T21:38:54Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 12, 2017, 2:48pm UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001/21 "2017-01-12T14:48:24Z")

</div>

> [@abhijith\_reddy](#):
>
> Does the per field memory usage returned \_cat/fielddata include global ordinals ?

Yes, it does.

> [@abhijith\_reddy](#):
>
> Since doc values is disk based, what does doc\_values\_memory\_in\_bytes give ?

The data associated with doc values is always on disk. However for certain types of docvalues there are small lookups (partly) in the jvm that contain file offsets for where to start looking for the actual data. The `doc_values_memory_in_bytes` stat reports the size of these lookups.

> [@abhijith\_reddy](#):
>
> Is there a way to measure the space consumed by global ordinals ?

Not directly. For fields with doc values enabled, the size of field data cache only includes the size of global ordinals. For fields that rely on field data (for example analyzed strings), as far as I know there is no good way to determine what the size of global ordinals are, as the field data size will include field data itself.

> [@abhijith\_reddy](#):
>
> Also I see conflicting things in the documentation related to fielddata and aggregations, [1] seems to suggest that fielddata wont be loaded but [2] says other wise. Is it possible to eagerly load global originals without triggering field data load.

In case for doc values fields with eager loading, only global ordinals will be loaded. In case for fields configured to use field data (by default that are analyzed string fields), field data has to be loaded. Global ordinals in that case depend on field data, without it can't be built.

---

<div class="post-metadata">

**Author:** ![abhijith\_reddy](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@abhijith\_reddy](https://discuss.elastic.co/u/abhijith_reddy)\
**Post date:** [January 12, 2017, 7:06pm UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001/22 "2017-01-12T19:06:27Z")

</div>

@mvg Thanks for the clarifications, this clears most things.  
I am still seeing a weird behaviour wrt to my last point.

When I update the mapping to

```
{
  'type' => 'string',
  'index' => 'not_analyzed',
  'doc_values' => true,
  'fielddata' => array(
    'format' => 'disabled',
    'loading' => 'eager_global_ordinals',
  )
}

```

and start indexing documents \_cat/fielddata reports 0b being used even after I issue flushes periodically. And aggregations still failed stating fielddata is disabled.

However when I remove 'format' =\> 'disabled' and repeat the process \_cat/fielddata does show memory being consumed.  
If global ordinals are being built using doc values then shouldn't aggregations have worked with fielddata being disabled ?

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 15, 2017, 9:05pm UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001/23 "2017-01-15T21:05:07Z")

</div>

By disabling field data the entire cache is disabled and thus global ordinals can't be stored either. So I guess that is why you don't see any memory being consumed. I haven't verified, but disabling field data would not make any of your search requests work even though doc values have been configured?

---

<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:** [February 12, 2017, 9:05pm UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001/24 "2017-02-12T21:05:08Z")

</div>

Closed on February 12, 2017, 9:05pm UTC

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

[Previous page](https://discuss.elastic.co/t/elasticsearch-aggregation-oom/71001.md?page=1)
