Restream / reindexer

Embeddable, in-memory, document-oriented database with a high-level Query builder interface.
https://reindexer.io
Apache License 2.0
763 stars 64 forks source link

Multiple aggregations #36

Closed wgh000 closed 5 years ago

wgh000 commented 5 years ago

Actually is not possible to Aggregate query per multiple columns related.

The code:

query.Aggregate("country", reindexer.AggFacet).Aggregate("city", reindexer.AggFacet)

is returning 2 slices

slice[0] = {"country1": 10, "country2": 20}
slice[1] = {"city1": 5, "city2": 20, "city3": 5}

It will be good to have a full aggregations, like MySql GROUP BY, returning

slice[0] = {["country": "country1", "city": "city1", "count": 10], ...}

Someone proposed to use the following construct

query.Aggregate("CONCAT(country, city)", reindexer.AggFacet)
olegator77 commented 5 years ago

This feature is available in new reindexer version. Check updated documentation: https://github.com/Restream/reindexer/blob/master/readme.md#aggregations