ES中查询数据使用date_histogram时报错
2017-07-21 16:40
274 查看
ES中,查询数据时,出现如下错误:
原因是由于使用date_histogram计算柱状图数据的时候,field的值,必须为数值型(int,date,Long等),出现这种情况,就是因为插入数据时,将field的类型定义为String型了。
解决办法:将field的数值类型改为Long或其他数值型
"reason": { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [validataTimeSeconds] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory." }
原因是由于使用date_histogram计算柱状图数据的时候,field的值,必须为数值型(int,date,Long等),出现这种情况,就是因为插入数据时,将field的类型定义为String型了。
解决办法:将field的数值类型改为Long或其他数值型
GET pi——2/event/_search { "size": 0, "query" : { "constant_score" : { "filter" : { "range" : { "validataTimeSeconds" : { "gte" : 1499654929, "lte" : 1499655380 } } } } }, "aggs" : { "by_time" : { "date_histogram" : { "field" : "validataTimeSeconds", "interval" : "100ms", "extended_bounds":{ "min" : 1499654929, "max" : 1499655380 } }, "aggs": { "event_status_group": { "filters": { "filters": { "NODATA":{ "match_phrase":{ "status":-1 } }, "ALERT":{ "match_phrase":{ "status":0 } }, "OK": { "match_phrase":{ "status":1 } } } } } } } } }
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [validataTimeSeconds] 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": "pi_2",
"node": "L-BYrdr3TKK17zNDXM1vTA",
"reason": { "type": "illegal_argument_exception", "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [validataTimeSeconds] 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 [validataTimeSeconds] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
}
},
"status": 400
}
相关文章推荐
- MyBatis中使用DATE_ADD()函数查询一个月的数据
- asp.net查询数据库时提示使用的sql server版本不支持数据类型date
- 关于myBatis与SQLserver 配合使用,查询类型为Date的数据时,日期会减少两天的问题
- Oracle中Date数据类型的操作和使用
- 如何使用ASP.NET查询和显示Excel数据
- MySQL5.0的三种数据类型:DATETIME, DATE和TIMESTAMP的使用
- Access使用查询--1.2.用选择查询进行分组数据的计算
- 如何使用 ASP.NET、ADO.NET 和 Visual C# .NET 查询和显示 Excel 数据
- 使用SQL查询DB2 9中的XML数据
- mysql中DATETIME、DATE 和 TIMESTAMP 类型数据使用
- 使用异步回调方式查询数据
- Scott Mitchell 的ASP.NET 2.0数据教程之四十八 使用SqlDataSource控件查询数据
- 使用异步回调方式查询数据
- 懒人摘抄(内容转自CSDN资源中教程)-数据查询04-使用聚合函数
- Scott Mitchell 的ASP.NET 2.0数据教程之48 使用SqlDataSource控件查询数据
- 使用 SQL 实现分季度查询汇总数据
- ORACLE用户常用数据字典的查询使用方法
- 使用ASP.NET(C#)查询和显示 Excel 数据
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之四十七:使用SqlDataSource控件查询数据
- 使用PL/Sql查询具有层次连接的数据