elasticsearch - 我的弹性平均查询错误 - 格式错误
问题描述
我得到了一个原因”:“[查询] 查询格式错误,查询名称后没有 start_object”错误,不知道为什么。
该查询旨在获取两个日期字段之间的差异并计算所有结果的平均值,我相信这应该有效,但可能无效。
任何帮助将不胜感激。
我在弹性版本 5.6.12
查询如下:
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)"
}
}
}
}
推荐阅读
- pdfbox - 字体 ArialMT 中使用的 OpenType 布局表未在 PDFBox 中实现
- neo4j - Neo4j Cypher 如何在 APOC neo4j cypher 查询中包含另一个父关系节点
- arrays - 如何将数组中的数据推送到对象中?
- c++ - 使用模板重载运算符
- hyperledger-fabric - 创建参与者的问题和身份问题 - 授权失败
- sql - 员工表 - 带有一些警告的层次结构
- ssl - 强制 Chrome 在 TLS 期间发送链中的所有证书
- angular - Angular 4 Highcharts - 需要在项目之间放置边距
- vba - 如何在同一个 Sub 中过滤、计数和循环
- python - 如何通过 .bat 文件调用 Pyinstaller?