# Understanding fielddata size

**URL:** <https://discuss.elastic.co/t/understanding-fielddata-size/199963>\
**Category:** Elasticsearch\
**Created:** [September 18, 2019, 9:33am UTC](https://discuss.elastic.co/t/understanding-fielddata-size/199963 "2019-09-18T09:33:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwinkler](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@cwinkler](https://discuss.elastic.co/u/cwinkler)\
**Post date:** [September 18, 2019, 9:33am UTC](https://discuss.elastic.co/t/understanding-fielddata-size/199963/1 "2019-09-18T09:33:31Z")

</div>

We are having a field containing path information like: a\>b\>c\>d  
The paths usually have a length of 4 segments.

The field is defined both as a keyword field and analyzed text using the path-tokenizer.  
Fielddata is enabled for the analyzed text field as we are running aggregations over the path segments.

I would have expected the size of fielddata for the text field to be at most 4 times that of the keyword field, as each value should result in 4 path entries like [a\>b\>c\>d, a\>b\>c, a\>b, a]

However, when using the cat API to list fielddata, I see about 100 **kb** for the keyword field (path.untouched), and 400 **mb** for the text field (path).

So, the ratio is about 4000 times larger.

Can anyone explain?

Here is the relevant excerpt from the mapping. Elasticsearch version is 6.4

```
"analysis": {
	"analyzer": {
		"path-analyzer": {
			"type": "custom",
			"tokenizer": "path-tokenizer",
			"filter": "lowercase"
		},
	"lowercase-analyzer": {
		"type": "custom",
		"tokenizer": "keyword",
		"filter": "lowercase"
	}
	},
	"tokenizer": {
		"path-tokenizer": {
			"type": "path_hierarchy",
			"delimiter": ">"
		}
	}
}
...
"properties": {
	"path": {
		"type": "text",
		"analyzer": "path-analyzer",
		"search_analyzer": "lowercase-analyzer",
		"fielddata": true,
		"fields": {
			"search": {
				"type": "text",
				"analyzer": "standard"
			},
			"untouched": {
				"type": "keyword"
			}
		}
	},...
```

---

<div class="post-metadata">

**Author:** ![cwinkler](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@cwinkler](https://discuss.elastic.co/u/cwinkler)\
**Post date:** [September 24, 2019, 1:59pm UTC](https://discuss.elastic.co/t/understanding-fielddata-size/199963/2 "2019-09-24T13:59:34Z")

</div>

Is there nobody that can help me with this excessive memory usage by fielddata?

In a production environment, fielddata occupies about 2gb for that single field.  
That really is an issue.

---

<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:** [October 22, 2019, 1:59pm UTC](https://discuss.elastic.co/t/understanding-fielddata-size/199963/3 "2019-10-22T13:59:40Z")

</div>

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