Elasticsearch how to set fielddata: true for all text fields Elasticsearch how to set fielddata: true for all text fields elasticsearch elasticsearch

Elasticsearch how to set fielddata: true for all text fields


you need to update the mapping of your field for this purpose you can usethe put mapping API of elasticsearch.

PUT yourindexName/_mapping/_doc{  "properties": {     "yourfield": {        "type":     "text",       "fielddata": true     }  }}

Although it is not advisable to enable the fielddata on text fields as they can consume a lot of heap space.

I suggest you to go through this link explaining the rationale behind this in detail. elasticsearch fielddata

Also alternatively you can try the below mapping for your fields:

 "yourfield": {     "type": "text",    "fields": {      "keyword": {        "type": "keyword"      }    }  }

Instead of plain text only...i hope it will serve your purpose.

Happy coding :)