fielddata is disabled on text fields API Origin: Application & API OSI layer 7 · Application Last updated 2 Dec 2026

Elasticsearch: illegal_argument_exception: Fielddata is disabled on text fields by default

A sort or aggregation targeted a text field, which is analysed and not sortable.

Exact message you may see Fielddata is disabled on text fields by defaultfielddata is disabled on text fieldsset fielddata=true
Seen on: Elasticsearch OpenSearch

Meaning

Aggregations and sorting need doc_values, available on keyword fields. Dynamic mappings create a text field with a .keyword sub-field.

Common causes

  • Aggregating on the text field instead of field.keyword
  • Mapping has no keyword sub-field
  • Enabling fielddata to silence the error (memory heavy)

⚡ Quick fix

  1. Use the .keyword sub-field in sort and aggs
  2. Map the field as keyword
  3. Avoid fielddata: true on large indices

Detailed fix by platform

Elasticsearch

  1. "aggs": {"by_city": {"terms": {"field": "city.keyword"}}}

How to diagnose

  1. Type — text or keyword?
  2. Subfield — .keyword exists?
  3. Memory — Heap pressure?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.