Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load

按照es官网教程聚合时出现问题,提示非法参数异常如下:

"type": "illegal_argument_exception",

Fielddata is disabled on text fields by default. Set fielddata=true on [interests] 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

默认fielddata在text字段上默认不起作用的,为了能够在内存中解析出倒排索引的字段数据,需要在interes的字段上开启fielddata,

注意如论如何尽量使用有意义的字段,或者是使用其他的字段来代替。

所以需要

PUT megacorp/_mapping/employee/
{
  "properties": {
    "interests": { 
      "type":     "text",
      "fielddata": true
    }
  }
}

然后执行es教程中的聚合语句

GET /megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": { "field": "interests" }
    }
  }
}

你可能感兴趣的:(elasticsearch,elasticsearch,聚合报错)