zoukankan      html  css  js  c++  java
  • Elasticsearch:修改fielddata

    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
        }
      }
    }
  • 相关阅读:
    ADFS登录界面自定义
    C# 不添加WEB引用调用WSDL接口
    C# 对象转XML 支持匿名类
    NSdata 与 NSString,Byte数组,UIImage 的相互转换
    《.NETer提高效率——环境部署》
    (五) Docker 安装 Nginx
    (六) Docker 部署 Redis 高可用集群 (sentinel 哨兵模式)
    (七) Docker 部署 MySql8.0 一主一从 高可用集群
    (八) Docker 部署 mongodb
    (四) Docker 使用Let's Encrypt 部署 HTTPS
  • 原文地址:https://www.cnblogs.com/fat-girl-spring/p/12855938.html
Copyright © 2011-2022 走看看