首页 > 其他 > 详细

Elasticsearch:修改fielddata

时间:2020-05-09 11:50:39      阅读:67      评论:0      收藏:0      [点我收藏+]
GET twitter/_search
{
  "query": {
    "match": {
      "city": "北京"
    }
  },
  "aggs":{
    "count_city":{
      "terms": {
        "field": "city"
      }
    }
  }
}

执行以上操作报错,报错内容如下:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [city] 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": "twitter",
        "node": "mFpXLptTTLKEMHwOAGFZjg",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [city] 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."
        }
      }
    ],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [city] 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.",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [city] 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
}

修改fielddata

PUT /twitter/_mapping/
{
  "properties": {
    "city": { 
      "type":     "text",
      "fielddata": true
    }
  }
}

Elasticsearch:修改fielddata

原文:https://www.cnblogs.com/fat-girl-spring/p/12855938.html

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