Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Workplace Search Analytics - Monthly Engagement Volume
{
"size": 0,
"query": {
"bool": {
"minimum_should_match": 1,
"should": [
{
"match": {
"event.action": "SearchMetrics.query"
}
},
{
"match": {
"event.action": "SearchMetrics.click"
}
}
]
}
},
"aggs": {
"date_ranges": {
"date_histogram": {
"field": "@timestamp",
"interval": "month"
},
"aggs": {
"queries": {
"filter": {
"term": {
"event.action": "SearchMetrics.query"
}
}
},
"clicks": {
"filter": {
"term": {
"event.action": "SearchMetrics.click"
}
}
},
"monthly_engagement": {
"bucket_script": {
"buckets_path": {
"query_count": "queries._count",
"click_count": "clicks._count"
},
"script": "params.click_count / params.query_count"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment