Hi All,
I have this query and I would like to bucketed results to be sorted on the managers age, can anybody help me on how to do this?
This is (a part of) my json request, the full request has multiple aggregates on ManagerJsonString:
{
"size": 0,
"query": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"terms": {
"ManagerId": [
115,
18,
123
]
}
}
]
}
}
]
}
},
"aggs": {
"ManagerJsonString": {
"filter": {
"multi_match": {
"type": "phrase_prefix",
"query": "pat",
"fields": [
"Manager.nl*.name^2",
"Manager.default.name"
]
}
},
"aggs": {
"aggr1": {
"terms": {
"field": "ManagerJsonString",
}
}
}
}
}
}
which results in this:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 257,
"max_score": 0,
"hits":
},
"aggregations": {
"ManagerJsonString": {
"doc_count": 2,
"aggr1": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [{
"key": "Manager;{"default":{"name":"Patrick","age":35},"nl":{"name":"Patrick","age":35}}",
"doc_count": 1
},
{
"key": "Manager;{"default":{"name":"Patricia","age":21},"nl":{"name":"Patricia","age":21}}",
"doc_count": 1
}]
}
}
}
}
Now the manager also has a property age as can be seen in the ManagerJsonString (which is an accumulation of some Manager fields) so how can I sort the buckets on the age of the manager?
I tried adding a sort on the aggr1 terms and could sort on the key and doc count but not on the age of the manager
Help would be appreciated I'm kind of stuck on this one.