Skip to content

Add support for TIMEOUT in FT.AGGREGATE and FT.SEARCH #2488

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 8 commits into from
May 21, 2023
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
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 @@ -454,6 +454,13 @@ describe('AGGREGATE', () => {
['FT.AGGREGATE', 'index', '*', 'DIALECT', '1']
);
});

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

testUtils.testWithClient('client.ft.aggregate', async client => {
Expand Down
5 changes: 5 additions & 0 deletions packages/search/lib/commands/AGGREGATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export interface AggregateOptions {
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
PARAMS?: Params;
DIALECT?: number;
TIMEOUT?: number;
}

export const FIRST_KEY_INDEX = 1;
Expand Down Expand Up @@ -213,6 +214,10 @@ export function pushAggregatehOptions(
args.push('DIALECT', options.DIALECT.toString());
}

if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}

return args;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/search/lib/commands/SEARCH.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ describe('SEARCH', () => {
['FT.SEARCH', 'index', 'query', 'DIALECT', '1']
);
});

it('with TIMEOUT', () => {
assert.deepEqual(
transformArguments('index', 'query', {
TIMEOUT: 5
}),
['FT.SEARCH', 'index', 'query', 'TIMEOUT', '5']
);
});
});

describe('client.ft.search', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/search/lib/commands/SEARCH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface SearchOptions {
};
PARAMS?: Params;
DIALECT?: number;
TIMEOUT?: number;
}

export function transformArguments(
Expand Down
4 changes: 4 additions & 0 deletions packages/search/lib/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ export function pushSearchOptions(
args.preserve = true;
}

if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}

return args;
}

Expand Down