# Fielddata memory usage

**URL:** https://discuss.elastic.co/t/fielddata-memory-usage/229550
**Category:** Elasticsearch
**Created:** [April 23, 2020, 9:18pm UTC](https://discuss.elastic.co/t/fielddata-memory-usage/229550 "2020-04-23T21:18:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)
#### Post date: [April 23, 2020, 9:18pm UTC](https://discuss.elastic.co/t/fielddata-memory-usage/229550/1 "2020-04-23T21:18:24Z")

</div>

Hi!

I've a v7.2.1 ES cluster and trying to lower heap memory usage. When I checked `GET /_cat/fielddata` I found a lot of non-text type fields in the list (e.g., "foo.keyword", "bar\_ip"). As far as I understood from the relevant [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html), those shouldn't appear in that list nor occupy heap memory. Any idea what am I missing?

Thanks!

---

<div class="post-metadata">

### Author: ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)
#### Post date: [April 24, 2020, 12:14am UTC](https://discuss.elastic.co/t/fielddata-memory-usage/229550/2 "2020-04-24T00:14:04Z")

</div>

Hello @YvorL,

The `GET _cat/fielddata` shows not only the `fielddata`, (which as you've said should be used only by `text` fields), but also `global ordinals`.

Our [documentation provides a quite good explanation](https://www.elastic.co/guide/en/elasticsearch/reference/master/eager-global-ordinals.html#_what_are_global_ordinals) on what they are and why they are generated.

A really great answer has been provided on a similar question: [Global ordinals performance and size on-heap](https://discuss.elastic.co/t/global-ordinals-performance-and-size-on-heap/158320/2)

If you're executing aggregations or sorting on `keyword` fields with high cardinality (e.g. a field which represents a unique id or, for example, the `_id` of the document), the global ordinals are generated and as they're expensive to generate, they're cached indefinitely ([by default](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-fielddata.html#modules-fielddata)).

Another collateral case where `global ordinals` are being used is when you're using Kibana KQL and you are using the auto-complete on the field `_id`. Kibana will trigger behind the scenes an aggregation on such field.

If the `global ordinals` have been loaded by mistake (a bad aggregation or a bad query), you can clean the cache using `POST /<index name>/_cache/clear?fielddata=true`. See [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html) about the clear cache API.

---

<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 22, 2020, 12:14am UTC](https://discuss.elastic.co/t/fielddata-memory-usage/229550/3 "2020-05-22T00:14:06Z")

</div>

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