Elasticsearch聚合操做报错解决办法

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

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

 

会报错:spa

"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便可解决:code

{
  "aggs": {
    "top_10_states": {
      "terms": {
        "field": "idc.keyword"
      }
    }
  }
}
相关文章
相关标签/搜索