In the test Elasticsearch polymerization time reported an error. details as follows:
GET /megacorp/employee/_search { "aggs": { "all_interests": { "terms": { "field": "interests" } } } }
Error Messages
{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead." } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true, "failed_shards": [ { "shard": 0, "index": "megacorp", "node": "wlvuJ0f_SsCxys6ZW5j7eA", "reason": { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead." } } ] }, "status": 400 }
solution:
1, ElasticSearch5.x solution is open fielddata of:
PUT /megacorp/_mapping/employee { "properties": { "interests": { "type": "text", "fielddata": true } } }
2, version ElasticSearch6.x or 7.x open fielddata when:
PUT /megacorp/_mapping { "properties": { "interests": { "type": "text", "fielddata": true } } }