elasticsearch 我的弹性平均查询中出错-格式不正确
我得到一个原因“[query]查询格式错误,查询名称后没有开始对象”错误,不确定原因 该查询旨在获取两个日期字段之间的差异,并计算所有结果的平均值,我认为这应该可行,但可能不可行 任何帮助都将不胜感激 我使用的是弹性版本5.6.12 查询如下:elasticsearch 我的弹性平均查询中出错-格式不正确,elasticsearch,kibana,elasticsearch,Kibana,我得到一个原因“[query]查询格式错误,查询名称后没有开始对象”错误,不确定原因 该查询旨在获取两个日期字段之间的差异,并计算所有结果的平均值,我认为这应该可行,但可能不可行 任何帮助都将不胜感激 我使用的是弹性版本5.6.12 查询如下: POST index_my.test/_search { "size":10, "query": { "bool": { "must": [ { "query":
POST index_my.test/_search
{
"size":10,
"query": {
"bool": {
"must": [
{
"query":
"match_all": {}
}
}
]
}
"filter": {
"and": [
{
"exists": {
"field": "activity.timeline.found"
}
}
{
"exists": {
"field": "activity.timeline.sent"
}
}
]
},
"aggs": {
"avg_timedifference": {
"avg": {
"script" : "Math.ceil(doc['activity.timeline.found'].value - doc['activity.timeline.sent'].value)"
}
}
}
}
您忘记在“筛选器”之前加逗号。请尝试以下操作:
POST index_my.test/_search
{
"size":10,
"query": {
"bool": {
"must": [
{
"query":
"match_all": {}
}
}
]
},
"filter": {
"and": [
{
"exists": {
"field": "activity.timeline.found"
}
}
{
"exists": {
"field": "activity.timeline.sent"
}
}
]
},
"aggs": {
"avg_timedifference": {
"avg": {
"script" : "Math.ceil(doc['activity.timeline.found'].value - doc['activity.timeline.sent'].value)"
}
}
}
}