我在索引中有“事件”(如网站点击)文档。现在,我要计算名称为x的事件与名称为y的事件之间的比率。我首先使用“过滤器” agg将我的文档分成两个存储桶,然后使用bucket_script聚合来计算比率,但是输出结果中未显示该结果...
这是我的查询:
GET /_search
{
"query": { ... },
"aggs": {
"all_my_documents": {
"filters": {
"filters": {
"all": { "match_all": {} }
}
},
"aggs": {
"bucket-aggregation-for-clicks-per-conversation": {
"filters": {
"filters": {
"presentation-clicks": { "term" : { "name" : "presentation-anchor-click" }},
"conversation-starts": { "term" : { "name" : "conversation-start" }}
}
}
},
"how-many-clicks-per-conversation": {
"bucket_script": {
"buckets_path": {
"my_clicks": "bucket-aggregation-for-clicks-per-conversation['presentation-clicks']>_count",
"my_starts": "bucket-aggregation-for-clicks-per-conversation['conversation-starts']>_count"
},
"script": "params.my_clicks / params.my_starts"
}
}
}
}
}
}
查询运行,结果我得到了两个存储桶,但是“如何每次对话如何多次”脚本似乎根本没有运行,因为输出中缺少该值:
...
"aggregations" : {
"all_my_documents" : {
"buckets" : {
"all" : {
"doc_count" : 5,
"bucket-aggregation-for-clicks-per-conversation" : {
"buckets" : {
"conversation-starts" : {
"doc_count" : 4
},
"presentation-clicks" : {
"doc_count" : 1
}
}
}
}
}
}
}
那么,为什么我的bucket_script“每次会话如何多次点击”未显示在输出中?我们将不胜感激!
预先感谢
安东