I'll do this indeed as soon as possible.
This is very useful but it doesn't take into consideration possible aggregations.
I mean, running the following query on the Dev Tools,
GET aggs_test/_search
{
"size": 0,
"aggs": {
"username": {
"terms": {
"field": "first.keyword"
},
"aggs": {
"outcomes": {
"terms": {
"field": "outcome.keyword"
}
}
}
}
}
}
I got something like this:
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 19,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"username" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "Alice",
"doc_count" : 9,
"outcomes" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "success",
"doc_count" : 6
},
{
"key" : "fail",
"doc_count" : 3
}
]
}
},
{
"key" : "Bob",
"doc_count" : 4,
"outcomes" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "fail",
"doc_count" : 2
},
{
"key" : "success",
"doc_count" : 2
}
]
}
},
{
"key" : "Charlie",
"doc_count" : 3,
"outcomes" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "fail",
"doc_count" : 2
},
{
"key" : "success",
"doc_count" : 1
}
]
}
},
{
"key" : "Derek",
"doc_count" : 3,
"outcomes" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "fail",
"doc_count" : 3
}
]
}
}
]
}
}
}
What should I add (bucket_script?) to the existing query to have only the Derek bucket returned?
Which is the way to make a comparison like "return only those buckets whose doc_count == key_fail>doc_count?"
I know I'm asking a lot but you're really helping!