Skip to content

Instantly share code, notes, and snippets.

@orcaman
Created August 13, 2015 17:15
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 orcaman/09bc12aca9912ab4e4c5 to your computer and use it in GitHub Desktop.
Save orcaman/09bc12aca9912ab4e4c5 to your computer and use it in GitHub Desktop.
es query
{
"size": 0,
"aggs": {
"group_by_campaignid": {
"terms": {
"field": "campaignid"
},
"aggs": {
"group_by_sellerid": {
"terms": {
"field": "sellerid"
},
"aggs": {
"group_by_pubid": {
"terms": {
"field": "pubid"
},
"aggs": {
"group_by_placementid": {
"terms": {
"field": "placementid"
},
"aggs": {
"adimpressions": {
"sum": {
"script": "doc['action'].value == 'adimpression' ? 1 : 0"
}
},
"adrequests": {
"sum": {
"script": "doc['action'].value == 'adrequest' ? 1 : 0"
}
}
}
}
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment