select * from (select street, count(street) as counts, min(grocery) as grocery, min(school) as school, (min(grocery) + min(school)) as score from geo_address group by 1) t order by grocery
I have geo_address index and I am creating column on the fly which is score that is sum of grocery column and school column.
Now it is sorted based on the grocery but I want to sort based on score. when I try to sort by it I get an error : - Cannot order by non-grouped column [score]. I asked this on Elasticsearch github issue page and I got response that this documented limitation of Elasticsearch here => Cannot order by non-grouped column[column name] · Issue #85894 · elastic/elasticsearch · GitHub
Is there other way around to work with this issue? How can write normal elastic query to achieve this? any help would be appreciated.