首页 > 其他 > 详细

ElasticSearch Fielddata is disabled

时间:2021-07-27 20:41:48      阅读:35      评论:0      收藏:0      [点我收藏+]

初次学习 Elasticsearch 在参照文档实例 挖掘出员工中最受欢迎的兴趣爱好 这一章节时,执行命令

curl -X GET "localhost:9200/megacorp/employee/_search?pretty" -H ‘Content-Type: application/json‘ -d‘{
  "aggs": {
    "all_interests": {
      "terms": { "field": "interests" }
    }
  }
}‘

出现如下的错误信息

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "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."
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "megacorp",
        "node": "8UDhP_KCSz6CNmKNyyFriQ",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "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."
        }
      }
    ]
  },
  "status": 400
}

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

curl -X PUT "localhost:9200/megacorp/_mapping/employee" -H ‘Content-Type: application/json‘ -d‘{
  "properties": {
    "interests": {
      "type": "text",
      "fielddata": true
    }
  }
}‘

ElasticSearch Fielddata is disabled

原文:https://www.cnblogs.com/zuojl/p/15066859.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!