# Understanding fielddata mapping parameter

**URL:** <https://discuss.elastic.co/t/understanding-fielddata-mapping-parameter/265798>\
**Category:** Elasticsearch\
**Created:** [March 1, 2021, 12:58pm UTC](https://discuss.elastic.co/t/understanding-fielddata-mapping-parameter/265798 "2021-03-01T12:58:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stravag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stravag/32/84723_2.png) [@stravag](https://discuss.elastic.co/u/stravag)\
**Post date:** [March 1, 2021, 12:58pm UTC](https://discuss.elastic.co/t/understanding-fielddata-mapping-parameter/265798/1 "2021-03-01T12:58:54Z")

</div>

I'm attempting to build a kind of "next word prediction" using elasticsearch. The goal is to have suggest search terms based on different fields of the index.

I found a solution based on the work done here [Search like a Google with Elasticsearch. Autocomplete, Did you mean and search for items. – Volodymyr Bilyachat](https://bilyachat.com/blog/search-like-google-with-elasticsearch) using aggregations on a "synthetic" suggestion field that uses a shingle filter.

This works to my expectations, but I had to enable `fielddata: true` on the suggestions field to get access to the parts created by the shingle filter and aggregating on them.

According to the documentation [Text field type | Elasticsearch Reference [7.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#fielddata-mapping-param) this: _"... load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory..."_

Can someone help me quantify what that can mean in terms of memory usage?

Let's say I have an index with 1million documents, and the suggestion field contains english sentences averaging 20 words. My 2/4 shingle filter would then create 74 tokens for each of those sentences.

Now when I query and aggregate terms on that field with few restrictions, what get's loaded into memory when `fielddata` is enabled, what can help me quantify that?

```auto
{
	"size": 0,
    "aggs": {
      "suggestions": {
	    "terms": {
		  "field": "suggestions",
	      "include": "c.*"
    	}
	  }
	},
	"query": {
      "prefix": {
    	"suggestions": {
    		"value": "c"
    	}
      }
	}
}

```

---

<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:** [March 29, 2021, 12:59pm UTC](https://discuss.elastic.co/t/understanding-fielddata-mapping-parameter/265798/2 "2021-03-29T12:59:01Z")

</div>

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