(转载)es进行聚合操作时提示Fielddata is disabled on text fields by default
2024-09-03 08:27:54
原文地址:http://blog.csdn.net/u011403655/article/details/71107415
根据es官网的文档执行
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests" }
}
}
}
这个例子时,报错
{
"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."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "megacorp",
"node": "-Md3f007Q3G6HtdnkXoRiA",
"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."
}
}
],
"caused_by": {
"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."
}
},
"status": 400
}
搜了一下应该是5.x后对排序,聚合这些操作用单独的数据结构(fielddata)缓存到内存里了,需要单独开启,官方解释在此fielddata(https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html)
简单来说就是在聚合前执行如下操作
PUT megacorp/_mapping/employee/
{
"properties": {
"interests": {
"type": "text",
"fielddata": true
}
}
}
最新文章
- C#4.0 特性
- Win7常规快捷键
- Linux下控制器IO地址
- 解惑:NFC手机如何轻松读取银行卡信息?
- sphinx下的max_matches取值对SetLimits的影响
- java二维码生成与解析代码实现
- 【leetcode】Divide Two Integers (middle)☆
- 【译】typeof null的前世今生
- hdu 5363Key Set
- RedHat Enterprise Linux 6.3 安装Oracle Database 11g
- ReactJs入门思路
- css3选择器:nth-child和nth-of-type之间的差别
- 【Git】 自动化Maven项目构建脚本(二)
- tf.train.ExponentialMovingAverage
- 对比剖析Swarm Kubernetes Marathon编排引擎
- 小妖精的完美游戏教室——东方PROJECT,同人,子机
- display: table-cell的实用应用
- 题解-bzoj4061 CERC-2012Farm and Factory
- react添加样式的四种方法
- c# 数据结构 ArrayList