Fielddata Disabled
Severity:
High
Elasticsearch Version:
8.5.0
Problem
Aggregations fail due to disabled fielddata on text fields
Root Cause
Fielddata is disabled on text fields, preventing aggregations on analyzed fields
How to Detect
Symptoms
- Aggregation queries return errors related to fielddata being disabled
- Elasticsearch logs show 'fielddata is disabled on text fields' messages
- Monitoring dashboards indicate failed aggregation metrics
Commands
GET /<index>/_mapping
GET /<index>/_search with 'explain' parameter
GET /_cluster/health
Remediation Steps
- Identify the text fields used in aggregations from the mapping
- Update the index mapping to enable fielddata on specific text fields: PUT /<index>/_mapping
- Add 'fielddata': true to the relevant text fields
- Reindex data if necessary to apply mapping changes
- Verify aggregation functionality after reindexing
Prevention
- Configure mappings with 'fielddata': true' on text fields intended for aggregations
- Use keyword sub-fields for aggregations to avoid enabling fielddata on text fields
- Implement index templates with predefined mappings for consistent field configurations
Production Example
curl -X PUT "localhost:9200/<index>/_mapping" -H 'Content-Type: application/json' -d '{"properties": {"your_text_field": {"type": "text", "fielddata": true}}}'