Skip to content

Instantly share code, notes, and snippets.

@jakab922
Created July 10, 2018 12:00
Show Gist options
  • Save jakab922/e9f257292cf097dbfefdb764bb26aaa5 to your computer and use it in GitHub Desktop.
Save jakab922/e9f257292cf097dbfefdb764bb26aaa5 to your computer and use it in GitHub Desktop.
Aggregated elastic query
{
"size": 0,
"query": {
"bool": {
"must": [
{ "exists": {"field": "status" } },
{ "exists": {"field": "class_name" } },
{ "exists": {"field": "test_name" } }
]
}
},
"aggs": {
"by_testcase": {
"terms": {
"size": 1000,
"script": {
"source": "doc['class_name.keyword'].value + '.' + doc['test_name.keyword'].value;",
"lang": "painless"
}
},
"aggs": {
"by_best_case": {
"max": {
"script": {
"lang": "painless",
"source": "if(doc['status'].value == 'pass') {return 2;} else if(doc['status'].value == 'skip') {return 1;} else {return 0;}"
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment