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 } } }
                    
                
                
            
        
浙公网安备 33010602011771号