Skip to content

Commit a85b051

Browse files
committed
revert the 'total' count logic in AGGREGATE response introduced in redis#2952
> FT.AGGREGATE returns an array reply where each row is an array reply and represents a single aggregate result. The integer reply at position 1 does not represent a valid value. https://redis.io/docs/latest/commands/ft.aggregate/#return
1 parent 5e9fea1 commit a85b051

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/search/lib/commands/AGGREGATE.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ export default {
156156
}
157157

158158
return {
159-
total: results.length,
159+
// https://redis.io/docs/latest/commands/ft.aggregate/#return
160+
// FT.AGGREGATE returns an array reply where each row is an array reply and represents a single aggregate result.
161+
// The integer reply at position 1 does not represent a valid value.
162+
total: Number(rawReply[0]),
160163
results
161164
};
162165
},

packages/search/lib/commands/PROFILE_AGGREGATE.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('PROFILE AGGREGATE', () => {
4545
const res = await client.ft.profileAggregate('index', '*');
4646

4747
const normalizedRes = normalizeObject(res);
48-
assert.equal(normalizedRes.results.total, 2);
4948

5049
assert.ok(normalizedRes.profile[0] === 'Shards');
5150
assert.ok(Array.isArray(normalizedRes.profile[1]));
@@ -73,7 +72,6 @@ describe('PROFILE AGGREGATE', () => {
7372
const normalizeObject = obj => JSON.parse(JSON.stringify(obj));
7473
const res = await client.ft.profileAggregate('index', '*');
7574
const normalizedRes = normalizeObject(res);
76-
assert.equal(normalizedRes.results.total, 2);
7775

7876
assert.ok(Array.isArray(normalizedRes.profile));
7977
assert.equal(normalizedRes.profile[0][0], 'Total profile time');
@@ -104,7 +102,6 @@ describe('PROFILE AGGREGATE', () => {
104102
const res = await client.ft.profileAggregate('index', '*');
105103

106104
const normalizedRes = normalizeObject(res);
107-
assert.equal(normalizedRes.Results.total_results, 2);
108105
assert.ok(normalizedRes.Profile.Shards);
109106
}, GLOBAL.SERVERS.OPEN_3);
110107
});

0 commit comments

Comments
 (0)