admin管理员组

文章数量:1640593

在用es查询的时候,有时候在按照 字符 格式进行聚合的时候,会报错:
Fielddata is disabled on text fields by default. Set fielddata=true on [client] 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.
这个错误最简单的解决方法就是加个“.keyword”

例如:
“aggregations”: {
“discount_per_type”: {
“terms”: {
“field”: “cnee_city”
} } }

改成 :
“aggregations”: {
“discount_per_type”: {
“terms”: {
“field”: “cnee_city.keyword”
} } }

当然这是最简单的方法,也有其他方法,但是比较复杂,不做记录了。

本文标签: 最简单TextFieldsdisabledDefault