GET flights/_search
{
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"whatever": {
"composite": {
"sources": [
{
"2": {
"terms": {
"script": {
"source": "if (doc['DestWeather.keyword'] == doc['OriginWeather.keyword']) return doc['DestWeather.keyword']; else return 'other';",
"lang": "painless"
}
}
}
}
]
}
}
},
"query": {
"match_all": {}
}
}
The idea originally surfaced in this discuss thread. The solution fit for SQL would include the
termsaggregation inside acompositeone to allow for pagination: