Skip to content

revert the 'total' count logic in AGGREGATE response introduced in #2952 #2955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/search/lib/commands/AGGREGATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ export default {
}

return {
total: results.length,
// https://redis.io/docs/latest/commands/ft.aggregate/#return
// 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.
total: Number(rawReply[0]),
results
};
},
Expand Down
14 changes: 11 additions & 3 deletions packages/search/lib/commands/PROFILE_AGGREGATE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ describe('PROFILE AGGREGATE', () => {
const res = await client.ft.profileAggregate('index', '*');

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

assert.ok(normalizedRes.profile[0] === 'Shards');
assert.ok(Array.isArray(normalizedRes.profile[1]));
Expand Down Expand Up @@ -73,7 +75,10 @@ describe('PROFILE AGGREGATE', () => {
const normalizeObject = obj => JSON.parse(JSON.stringify(obj));
const res = await client.ft.profileAggregate('index', '*');
const normalizedRes = normalizeObject(res);
assert.equal(normalizedRes.results.total, 2);

// TODO uncomment after https://redis.io/docs/latest/commands/ft.aggregate/#return
// starts returning valid values
// assert.equal(normalizedRes.results.total, 2);

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

// TODO uncomment after https://redis.io/docs/latest/commands/ft.aggregate/#return
// starts returning valid values
// assert.equal(res.Results.total_results, 2);

const normalizedRes = normalizeObject(res);
assert.equal(normalizedRes.Results.total_results, 2);
assert.ok(normalizedRes.Profile.Shards);
}, GLOBAL.SERVERS.OPEN_3);
});
Loading