At the moment something like select (3 < languages) as multi_language, count(*) from test_emp group by multi_language doesn't work. The exception is not entirely accurate in my opinion and the ES query used in this scenario is very similar with the one from #34400.
{
"size": 0,
"aggs": {
"NAME": {
"composite": {
"sources": [
{
"product": {
"terms": {
"script": {
"source": "doc['languages'].value > 3",
"lang": "painless"
}
}
}
}
]
}
}
}
}