zoukankan      html  css  js  c++  java
  • ES 聚合分类(text字段)语句报错

    {
      "query": {
        "bool": {
          "must": {
            "term": {
              "type.keyword": "test"
            }
          }
        }
      },
      "from": 0,
      "size": 0,
      "sort": [
        {
          "msg_time": {
            "order": "desc"
          }
        }
      ],
      "aggs": {
        "myName": {
          "terms": {
            "field": "xxxx"
          }
        }
      }
    }
    

      报错信息如下:

    Fielddata is disabled on text fields by default. Set fielddata=true on [title] 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.

           使用ES版本为:5.1.1

      解决办法:

      

    PUT my-index-000001/_mapping/type
    {
      "properties": {
        "my_field": { 
          "type":     "text",
          "fielddata": true
        }
      }
    }

     最新版本不需要type

    PUT my-index-000001/_mapping
    {
      "properties": {
        "my_field": { 
          "type":     "text",
          "fielddata": true
        }
      }
    }
  • 相关阅读:
    python安装
    实现node服务器
    VSCode集成tomcat及使用方法
    CommonJS规范
    Bootstrap 笔记
    vue笔记
    jgGrid模板添加
    vue组件中的data
    解析DNS
    StaticResource
  • 原文地址:https://www.cnblogs.com/foreverYoungCoder/p/13652944.html
Copyright © 2011-2022 走看看