1. 当根据一个类型为text的字段idc进行聚合操作时,查询语句如下:

{
"aggs": {
"top_10_states": {
"terms": {
"field": "idc"
}
}
}
}

会报错:

"Fielddata is disabled on text fields by default. Set fielddata=true on [idc] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."

解决办法,在构建查询语句时,给字段添加.keyword即可解决:

{
"aggs": {
"top_10_states": {
"terms": {
"field": "idc.keyword"
}
}
}
}
05-08 15:42