Skip to content

Commit ebd0303

Browse files
authored
revert the 'total' count logic in AGGREGATE response introduced in #2952 (#2955)
> 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 ebd0303

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ describe('PROFILE AGGREGATE', () => {
4545
const res = await client.ft.profileAggregate('index', '*');
4646

4747
const normalizedRes = normalizeObject(res);
48-
assert.equal(normalizedRes.results.total, 2);
48+
// TODO uncomment after https://redis.io/docs/latest/commands/ft.aggregate/#return
49+
// starts returning valid values
50+
// assert.equal(normalizedRes.results.total, 2);
4951

5052
assert.ok(normalizedRes.profile[0] === 'Shards');
5153
assert.ok(Array.isArray(normalizedRes.profile[1]));
@@ -73,7 +75,10 @@ describe('PROFILE AGGREGATE', () => {
7375
const normalizeObject = obj => JSON.parse(JSON.stringify(obj));
7476
const res = await client.ft.profileAggregate('index', '*');
7577
const normalizedRes = normalizeObject(res);
76-
assert.equal(normalizedRes.results.total, 2);
78+
79+
// TODO uncomment after https://redis.io/docs/latest/commands/ft.aggregate/#return
80+
// starts returning valid values
81+
// assert.equal(normalizedRes.results.total, 2);
7782

7883
assert.ok(Array.isArray(normalizedRes.profile));
7984
assert.equal(normalizedRes.profile[0][0], 'Total profile time');
@@ -103,8 +108,11 @@ describe('PROFILE AGGREGATE', () => {
103108
const normalizeObject = obj => JSON.parse(JSON.stringify(obj));
104109
const res = await client.ft.profileAggregate('index', '*');
105110

111+
// TODO uncomment after https://redis.io/docs/latest/commands/ft.aggregate/#return
112+
// starts returning valid values
113+
// assert.equal(res.Results.total_results, 2);
114+
106115
const normalizedRes = normalizeObject(res);
107-
assert.equal(normalizedRes.Results.total_results, 2);
108116
assert.ok(normalizedRes.Profile.Shards);
109117
}, GLOBAL.SERVERS.OPEN_3);
110118
});

0 commit comments

Comments
 (0)