默认情况下,文本字段中的ElasticSearch 5.1 Fielddata是禁用的[错误:尝试在字段上使用聚合] [英] ElasticSearch 5.1 Fielddata is disabled in text field by default [ERROR: trying to use aggregation on field]

查看:381
本文介绍了默认情况下,文本字段中的ElasticSearch 5.1 Fielddata是禁用的[错误:尝试在字段上使用聚合]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的映射中有此字段

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

Do i have to change my mapping or am i using the wrong aggregation ? (just updated from 2.x to 5.1)

推荐答案

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

You need to aggregate on the keyword sub-field, like this:

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

那行得通.

这篇关于默认情况下,文本字段中的ElasticSearch 5.1 Fielddata是禁用的[错误:尝试在字段上使用聚合]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆