Elasticsearch 6.2.3版本 执行聚合报错 Fielddata is disabled on text fields by default
背景说明
执行《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的更多相关文章
- Elasticsearch 6.2.3版本 string 类型字段 排序 报错 Fielddata is disabled on text fields by default
背景说明 最近在做一个 Elasticsearch 的分页查询,并且对查询结果按照特定字段进行排序的功能. 但是执行结果却报错,报错信息如下: { "error": { " ...
- ES 查询时 排序报错(fielddata is disabled on text fileds by default ... )解决方法
背景:elasticsearch 进行排序的时候,可能会排序数字.日期.但是在排序text类型的时候就会出现上述错误 原因(参考): https://blog.csdn.net/wild46cat/a ...
- elasticsearch报Fielddata is disabled on text fields by default
我刚玩elk没几天,今天启动kibana之后执行查询看见elasticsearch报了一个错误 Caused by: java.lang.IllegalArgumentException: Field ...
- 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 ...
- (转载)es进行聚合操作时提示Fielddata is disabled on text fields by default
原文地址:http://blog.csdn.net/u011403655/article/details/71107415 根据es官网的文档执行 GET /megacorp/employee/_se ...
- (转)es进行聚合操作时提示Fielddata is disabled on text fields by default
根据es官网的文档执行 GET /megacorp/employee/_search { "aggs": { "all_interests": { " ...
- es进行聚合操作时提示Fielddata is disabled on text fields by default
在进行派粗前,先执行以下操作 { "properties": { "updatedate": { "type": "text&qu ...
- IE8.0.6001这个版本执行JS报错
现场: OS winserver 2008 IE8.0.6001.18702 JS报错,不能登陆 OS XP IE8.0.6001.18702CO JS报错,不能登陆 公司测试: ...
- ES聚合报错
在测试Elasticsearch聚合的时候报了一个错误.具体如下: GET /megacorp/employee/_search { "aggs": { "all_int ...
随机推荐
- Android单元测试之google官例CalculatorTest
执行测试用例类CalculatorTest 设置genymotion可见: Android Studio界面中,依次单击菜单项 View >Toolbar.即可见改工具按钮. 启动gen ...
- 前端面试题-CSS Hack
一.CSS Hack的概念 由于不同厂商的流览器或某浏览器的不同版本(如IE,Firefox/Safari/Opera/Chrome等),对CSS的支持.解析不一样,导致在不同浏览器的环境中呈现出不一 ...
- vs code 写VUE代码 注释 html出现 //
装个插件 "Vuter" 解决
- 【leetcode】1258. Synonymous Sentences
题目如下: Given a list of pairs of equivalent words synonyms and a sentence text, Return all possible sy ...
- Python 文件I/OⅡ
File对象的属性 一个文件被打开后,你有一个file对象,你可以得到有关该文件的各种信息. 以下是和file对象相关的所有属性的列表: 如下实例: 以上实例输出结果: close()方法 File ...
- AOP 实现日志
package com.foen.foensys.config; import com.alibaba.fastjson.JSON;import com.foen.foensys.model.SysL ...
- 并行计算基础(1)(GPU架构介绍)
一.常用术语 Task:任务.可以完整得到结果的一个程序,一个程序段或若干个程序段.例如搬砖. Parallel Task:并行任务.可以并行计算的任务.多个人搬砖. Serial Execution ...
- Arthas--Java在线分析诊断工具(阿尔萨斯)
序言 Arthas是一款阿里巴巴开源的 Java 线上诊断工具,功能非常强大,可以解决很多线上不方便解决的问题. 资料 https://blog.csdn.net/youanyyou/article/ ...
- JS大文件上传断点续传解决方案
1 背景 用户本地有一份txt或者csv文件,无论是从业务数据库导出.还是其他途径获取,当需要使用蚂蚁的大数据分析工具进行数据加工.挖掘和共创应用的时候,首先要将本地文件上传至ODPS,普通的小文件通 ...
- spring整合之后运行报什么只读错误。Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
解决办法, 再大dao的实现类上添加注解: @Transactional(readOnly = false ) 不让它只读就行了