Search code examples
mysqlredisaggregateredisearch

Redis Redisearch Aggregate GroupBy multiple column


I would like to in redisearch a query similar to :

SELECT groupA, groupB, sum(value) as totalvalue FROM tableA WHERE groupC = 'C' GROUP BY groupA, groupB

How can I do it in redisearch? Is it possible?


I can only do one group at the moment :

FT.AGGREGATE ResultSearch "@groupC:C" GROUPBY 1 @groupA REDUCE SUM 1 @value as totalvalue SORTBY 2 @groupA ASC

which is similar to something like this in sql:

SELECT groupA, sum(value) as totalvalue FROM tableA WHERE groupC = 'C' GROUP BY groupA

But how to do multiple groups in Redisearch?

I am still very new to Redisearch, sorry for a very basic question. Thank you so much for your help.


Solution

  • you can use :

    FT.AGGREGATE ResultSearch "@groupC:C" GROUPBY 2 @groupA @groupB REDUCE SUM 1 @value as totalvalue SORTBY 2 @groupA ASC