通过下面的聚合并使用 ES5,我想根据给定时区(作为 TZ 数据库中的标识符提供)获取 dayOfWeek 和 hourOfDay。
我怎样才能编辑"doc['created'].date.dayOfWeek'
调整偏移量?
aggs: {
dayOfWeek: {
terms: {
script: {
inline: "doc['created'].date.dayOfWeek",
lang: 'painless',
},
},
aggs: {
hourOfDay: {
terms: {
script: {
inline: "doc['created'].date.hourOfDay",
lang: 'painless',
},
},
},
},
},
},
找到了使用无痛的解决方案。因为他们正在将elasticsearch从Joda迁移到原生java.time,所以对Joda的支持并不好。
{
"size": 0,
"aggregations": {
"dayOfWeek": {
"terms": {
"script": {
"inline": "Instant.ofEpochMilli(doc.created.date.millis).atZone(ZoneId.of(params.tz)).dayOfWeek",
"params": {
"tz": "Europe/London"
}
}
},
"aggs": {
"hourOfDay": {
"terms": {
"script": {
"inline": "Instant.ofEpochMilli(doc.created.date.millis).atZone(ZoneId.of(params.tz)).hour",
"params": {
"tz": "Europe/London"
}
}
}
}
}
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)