Elasticsearch聚合操作报错解决办法

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"
      }
    }
  }
}

 

posted @ 2019-06-27 09:51  明天OoO你好  阅读(646)  评论(0编辑  收藏  举报