Skip to content

Aggregation query: toList reducer doesn't generate the expected list #342

Closed
@andy-stark-redis

Description

@andy-stark-redis

NRedisStack Version: current master branch

Redis Stack Version: 7.2.4

Description:
I attempted to write a code sample for the aggregation query doc page. Under Grouping without aggregation, there is an example that uses the toList reducer. The equivalent code for jedis and redis-py works OK but the NRedisStack code shown below doesn't actually add any output from the reducer:

AggregationResult res4 = db.FT().Aggregate(
            "idx:bicycle",
            new AggregationRequest("*")
                .Load(new FieldName("__key"))
                .GroupBy(
                    "@condition",
                    Reducers.ToList("__key").As("bicycles")
                )
        );
        Console.WriteLine(res4.TotalResults);   // >>> 3

        for (int i = 0; i < res4.TotalResults; i++)
        {
            Row res4Row = res4.GetRow(i);
            var res = $"Condition: {res4Row["condition"]}, Bicycles: {res4Row["bicycles"]}";
            Console.WriteLine(res);
        }
        // Should be an array of bicycle:x at the end of each line but nothing appears after "Bicycles:"

        // >>> Condition: refurbished, Bicycles: 
        // >>> Condition: used, Bicycles: 
        // >>> Condition: new, Bicycles: 

The "bicycles" index and the JSON objects are working correctly, btw, and are used elsewhere successfully in the same page. There appears to be an old issue in the StackExchange repo that is similar but I don't know for sure if it is referring to the same problem.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions