Created
March 1, 2015 22:00
-
-
Save jkbnerad/8e8f4de5c4ec1407d86a to your computer and use it in GitHub Desktop.
Elasticsearch - aggregations
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
doc['exits'].value > 0) ? doc['orders'].value / doc['exits'].value : 0 |
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
{ | |
"query": { | |
"filtered": { | |
"query": {"match_all": {}}, | |
"filter": {"range": { | |
"date": { | |
"from": "2014-03-01", | |
"to": "2015-02-28" | |
} | |
}} | |
} | |
}, | |
"aggs": { | |
"counts" : { | |
"terms": { | |
"field": "variant", | |
"order": { | |
"exits": "desc" | |
} | |
}, | |
"aggs" : { | |
"exits" : { | |
"sum" : {"field":"exits"} | |
}, | |
"orders" : { | |
"sum" : {"field" : "orders"} | |
}, | |
"rate" : { | |
"avg" : {"script" : "agg_rate"} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment