Skip to content

Commit

Permalink
add addscores to aggregate search command (#2799)
Browse files Browse the repository at this point in the history
* add addscores to aggregate search command

* change `true` to `boolean`

---------

Co-authored-by: Leibale Eidelman <me@leibale.com>
  • Loading branch information
sjpotter and leibale authored Jul 29, 2024
1 parent 6f79b49 commit 54b3e17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/search/lib/commands/AGGREGATE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ describe('AGGREGATE', () => {
);
});

it('with ADDSCORES', () => {
assert.deepEqual(
transformArguments('index', '*', { ADDSCORES: true }),
['FT.AGGREGATE', 'index', '*', 'ADDSCORES']
);
});

describe('with LOAD', () => {
describe('single', () => {
describe('without alias', () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/search/lib/commands/AGGREGATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ type LoadField = PropertyName | {
}

export interface AggregateOptions {
VERBATIM?: true;
VERBATIM?: boolean;
ADDSCORES?: boolean;
LOAD?: LoadField | Array<LoadField>;
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
PARAMS?: Params;
Expand Down Expand Up @@ -150,6 +151,10 @@ export function pushAggregatehOptions(
args.push('VERBATIM');
}

if (options?.ADDSCORES) {
args.push('ADDSCORES');
}

if (options?.LOAD) {
args.push('LOAD');
pushArgumentsWithLength(args, () => {
Expand Down Expand Up @@ -308,4 +313,4 @@ export function transformReply(rawReply: AggregateRawReply): AggregateReply {
total: rawReply[0],
results
};
}
}

0 comments on commit 54b3e17

Please sign in to comment.