一尘不染

默认情况下,文本字段中的ElasticSearch 5.1 Fielddata是禁用的[错误:尝试在字段上使用聚合]

elasticsearch

在我的映射中包含此字段

"answer": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },

我尝试执行此聚合

"aggs": {
"answer": {
  "terms": {
    "field": "answer"
  }
},

但我得到这个错误

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

我必须更改映射还是使用错误的聚合?(仅从2.x更新到5.1)


阅读 346

收藏
2020-06-22

共1个答案

一尘不染

您需要在keyword子字段上进行汇总,如下所示:

"aggs": {
"answer": {
  "terms": {
    "field": "answer.keyword"
  }
},

那可行。

2020-06-22