在我的映射中包含此字段
"answer": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } },
我尝试执行此聚合
"aggs": { "answer": { "terms": { "field": "answer" } },
但我得到这个错误
"type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [answer] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
我必须更改映射还是使用错误的聚合?(仅从2.x更新到5.1)
您需要在keyword子字段上进行汇总,如下所示:
keyword
"aggs": { "answer": { "terms": { "field": "answer.keyword" } },
那可行。