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 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
textfield instead offield.keyword - Mapping has no keyword sub-field
- Enabling fielddata to silence the error (memory heavy)
⚡ Quick fix
- Use the
.keywordsub-field in sort and aggs - Map the field as
keyword - Avoid
fielddata: trueon large indices
Detailed fix by platform
Elasticsearch
"aggs": {"by_city": {"terms": {"field": "city.keyword"}}}
How to diagnose
- Type — text or keyword?
- Subfield — .keyword exists?
- 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:
Most viewed in API
Other ways to find it
🧠 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.
Did this fix work for you?
Report a correction or suggest an improvement
Last updated 2 Dec 2026