es aggs Fielddata is disabled on text fields by default. Set fielddata=true on [inte

按照官网es 执行aggs 的出现问题

Fielddata is disabled on text fields by default. Set fielddata=true on [inte

具体原因是聚合需要大量的内存,聚合前,需要将相应的字段开启聚合

PUT megacorp/_mapping/employee/
{
  "properties": {
    "interests": { 
      "type":     "text",
      "fielddata": true
    }
  }
}
GET /megacorp/employee/_search
{
    "aggs" : {
        "all_interests" : {
            "terms" : { "field" : "interests" },
            "aggs" : {
                "avg_age" : {
                    "avg" : { "field" : "age" }
                }
            }
        }
    }
}

参考

你可能感兴趣的:(es)