Skip to content

Instantly share code, notes, and snippets.

@markjhoy
Created January 26, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markjhoy/15a2226f0b40b18bf1446176364bf43d to your computer and use it in GitHub Desktop.
Save markjhoy/15a2226f0b40b18bf1446176364bf43d to your computer and use it in GitHub Desktop.
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