背景说明

执行《Elasticsearch 权威指南》的示例,在执行聚合查询的时候,报错 Fielddata is disabled on text fields by default.

1)聚合语句如下:

GET _search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests"}
}
}
}

2)报错信息如下:

{
"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": "jbFtoSVqQAqfYhE5uTBFvw",
"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
}

3)Kibana 的 Dev Tools 执行截图如下:

原因分析

Elasticsearch 5.x版本以后,对排序和聚合等操作,用单独的数据结构(fielddata)缓存到内存里了,默认是不开启的需要单独开启

具体请参考:fielddata

解决方案

1)执行如下语句,将 interests字段进行开启映射mapping:

PUT megacorp/_mapping/employee/
{
"properties":{
"interests":{
"type":"text",
"fielddata":true
}
}
}

2)Kibana 的 Dev Tools 中执行开启映射mapping语句,截图如下:

3)再次实行聚合语句,结果如下:

{
"took": 455,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1,
"hits": [
{
"_index": "megacorp",
"_type": "employee",
"_id": "2",
"_score": 1,
"_source": {
"first_name": "Jane",
"last_name": "Smith",
"age": 32,
"about": "I like to collect rock albums",
"interests": [
"music"
]
}
},
{
"_index": "megacorp",
"_type": "employee",
"_id": "1",
"_score": 1,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports"
]
}
},
{
"_index": "megacorp",
"_type": "employee",
"_id": "3",
"_score": 1,
"_source": {
"first_name": "Douglas",
"last_name": "Fir",
"age": 35,
"about": "I like to build cabinets",
"interests": [
"forestry"
]
}
}
]
},
"aggregations": {
"all_interests": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "forestry",
"doc_count": 1
},
{
"key": "music",
"doc_count": 1
},
{
"key": "sports",
"doc_count": 1
}
]
}
}
}

4)Kibana 的 Dev Tools 中,执行效果截图如下:

Elasticsearch 6.2.3版本 执行聚合报错 Fielddata is disabled on text fields by default的更多相关文章

  1. Elasticsearch 6.2.3版本 string 类型字段 排序 报错 Fielddata is disabled on text fields by default

    背景说明 最近在做一个 Elasticsearch 的分页查询,并且对查询结果按照特定字段进行排序的功能. 但是执行结果却报错,报错信息如下: { "error": { " ...

  2. ES 查询时 排序报错(fielddata is disabled on text fileds by default ... )解决方法

    背景:elasticsearch 进行排序的时候,可能会排序数字.日期.但是在排序text类型的时候就会出现上述错误 原因(参考): https://blog.csdn.net/wild46cat/a ...

  3. elasticsearch报Fielddata is disabled on text fields by default

    我刚玩elk没几天,今天启动kibana之后执行查询看见elasticsearch报了一个错误 Caused by: java.lang.IllegalArgumentException: Field ...

  4. Elasticsearch 报错:Fielddata is disabled on text fields by default. Set `fielddata=true` on [`your_field_name`] in order to load fielddata in memory by uninverting the inverted index.

    Elasticsearch 报错: Fielddata is disabled on text fields by default. Set `fielddata=true` on [`your_fi ...

  5. (转载)es进行聚合操作时提示Fielddata is disabled on text fields by default

    原文地址:http://blog.csdn.net/u011403655/article/details/71107415 根据es官网的文档执行 GET /megacorp/employee/_se ...

  6. (转)es进行聚合操作时提示Fielddata is disabled on text fields by default

    根据es官网的文档执行 GET /megacorp/employee/_search { "aggs": { "all_interests": { " ...

  7. es进行聚合操作时提示Fielddata is disabled on text fields by default

    在进行派粗前,先执行以下操作 { "properties": { "updatedate": { "type": "text&qu ...

  8. IE8.0.6001这个版本执行JS报错

    现场: OS  winserver 2008 IE8.0.6001.18702   JS报错,不能登陆 OS  XP   IE8.0.6001.18702CO     JS报错,不能登陆 公司测试: ...

  9. ES聚合报错

    在测试Elasticsearch聚合的时候报了一个错误.具体如下: GET /megacorp/employee/_search { "aggs": { "all_int ...

随机推荐

  1. Python测试开发必知必会-PEP

    互联网发展了许多年,不仅颠覆了很多行业,还让很多职位有了更多的用武之地.产品发布迭代速度不断加快,让测试开发这个岗位简直火得不要不要的. Python语言,作为一种更接近人来自然语言的开发语言,以简洁 ...

  2. oracle修改某个表的字段顺序

    有时候会发现某个表的列顺序不理想,想修改 -1查询表, select * from AIRWAY_TYPE t --2 查询用户和表名,找到obj#,select object_id from all ...

  3. nginx搭建及加固

    系统使用的是centos7 Nginx安装及配置 Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务 安装 我是用的环境是ce ...

  4. 亲爱的SAP从业者们,烦请做个SAP知识学习种类的小调查

    "世上再也没有比时钟更加冷漠的东西了:在您出生的那一刻,在您尽情地摘取青春幻梦的花朵的时刻,它都是同样分秒不差地滴答着." -- 高尔基 2019年马上又要离我们而去了,从2018 ...

  5. java 枚举的用法

    public enum StatisticTableEnum { DOC_BROWSE_STATISTIC("doc_browse_statistic"), DOC_LIB_BRO ...

  6. https://github.com/zabbix/zabbix-docker 安装

    docker-compose -f ./docker-compose_v3_centos_mysql_latest.yaml up -d 解压文件,运行即可

  7. 【leetcode】1235. Maximum Profit in Job Scheduling

    题目如下: We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtai ...

  8. 命令行执行while语句

    while true;do echo hello world;sleep 1;done

  9. javascript中的原型和原型链(二)

    原型(prototype) 函数的 prototype 属性(图) 每个函数都有一个prototype属性,它默认指向一个Object空对象(即称为:原型对象) 原型对象中有一个属性construct ...

  10. Codeforces Round #578 (Div. 2) Solution

    Problem A Hotelier 直接模拟即可~~ 复杂度是$O(10 \times n)$ # include<bits/stdc++.h> using namespace std; ...