Created
January 26, 2021 15:27
-
-
Save markjhoy/a338439af2bc84330aeff63ca4e93f3c to your computer and use it in GitHub Desktop.
Workplace Search Analytics - Weekly User Retention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"size": 0, | |
"query": { | |
"bool": { | |
"minimum_should_match": 1, | |
"should": [ | |
{ "match": { "event.action": "SearchMetrics.query" } } | |
] | |
} | |
}, | |
"aggs": { | |
"date_ranges": { | |
"date_histogram": { | |
"field": "@timestamp", | |
"interval": "week" | |
}, | |
"aggs": { | |
"unique_users": { | |
"cardinality": { | |
"field": "source.user.id" | |
} | |
}, | |
"weekly_user_retention": { | |
"moving_fn": { | |
"buckets_path": "unique_users", | |
"window": 2, | |
"script": "return values.length > 1 ? values[1]/values[0] : Double.NaN" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment