简单的日期直方图? [英] Simple date histogram?
本文介绍了简单的日期直方图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据格式如下:
{text:hi,created_at: 2016-02-21T18:30:36.000Z}
为此,我使用 dateConversion.groovy
脚本并保存在ES 5.1.1的脚本文件夹中。
日期日期=新日期(doc [date_field] .value);
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat(format);
format.format(date)
当我在ES PLUGIN中执行以下代码时:
aggs:{
byDays:{
terms:{
脚本:{
lang:groovy,
file:dateConversion,
params:{
date_field:created_at,
format:EEEEEE
}
}
}
}``
我得到这样一个异常:
error:{
root_cause:[
{
type:illegal_argument_exception,
reason :无法在lang [groovy]
}
],
type:search_phase_execution_exception,
reason中找到磁盘文件脚本[dateConversion]:所有碎片失败,
phase:query,
分组:true,
failed_shards:[
{
shard:0,
index:testindex-stats,
node:vVhZxH7pQ7CO3qpbYm_uew,
reason:{
type:illegal_argument_exception,
reason:无法使用lang [groovy]在磁盘文件脚本[dateConversion]上查找
}
causes_by:{
type:illegal_argument_exception,
reason:无法在磁盘文件脚本中找到[ dateConversion]使用lang [groovy]
}
},
status:400
}
解决方案
我的代码的某些部分需要修改
aggs:{
byDays:{
terms:{
script:{
file:测试,
params:{
date_field:created_at,
format:EEEEEE
}
}
}
}
还有我的test.groovy代码
Date date = new Date(doc [date_field] .value);
date.format(format);
Viewing documents on per weekday classification? My data is in a format like this:
{"text": "hi","created_at": "2016-02-21T18:30:36.000Z"}
For this I am using a dateConversion.groovy
script and kept in the scripts folder in ES 5.1.1.
Date date = new Date(doc[date_field].value);
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat(format);
format.format(date)
When I executed the following code in ES PLUGIN:
"aggs": {
"byDays": {
"terms": {
"script": {
"lang": "groovy",
"file": "dateConversion",
"params": {
"date_field": "created_at",
"format": "EEEEEE"
}
}
}
} ``
I am getting an exception like this:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Unable to find on disk file script [dateConversion] using lang [groovy]"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "testindex-stats",
"node": "vVhZxH7pQ7CO3qpbYm_uew",
"reason": {
"type": "illegal_argument_exception",
"reason": "Unable to find on disk file script [dateConversion] using lang [groovy]"
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Unable to find on disk file script [dateConversion] using lang [groovy]"
}
},
"status": 400
}
解决方案
Some parts of my code need some modifications
{
"aggs": {
"byDays": {
"terms": {
"script":{
"file":"test",
"params": {
"date_field": "created_at",
"format": "EEEEEE"
}
}
}
}
}
}
And also my test.groovy code too
Date date = new Date(doc[date_field].value);
date.format(format);
这篇关于简单的日期直方图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文