You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add support for TIMEOUT
in FT.AGGREGATE
and FT.SEARCH
(#2488)
* #2486: add timeout as optional param in FT.Search * return timeout from aggregate * add test case for TIMEOUT in aggregate * add TIMEOUT option in search file * add test cases for TIMEOUT option in search file * uodate search/aggregates to add timeout when it is not undefuned * update search to add timeout when it is not undefuned * update test case for AGGREGATE
This commit is contained in:
@@ -454,6 +454,13 @@ describe('AGGREGATE', () => {
|
|||||||
['FT.AGGREGATE', 'index', '*', 'DIALECT', '1']
|
['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 => {
|
testUtils.testWithClient('client.ft.aggregate', async client => {
|
||||||
|
@@ -124,6 +124,7 @@ export interface AggregateOptions {
|
|||||||
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
|
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
|
||||||
PARAMS?: Params;
|
PARAMS?: Params;
|
||||||
DIALECT?: number;
|
DIALECT?: number;
|
||||||
|
TIMEOUT?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export const FIRST_KEY_INDEX = 1;
|
||||||
@@ -213,6 +214,10 @@ export function pushAggregatehOptions(
|
|||||||
args.push('DIALECT', options.DIALECT.toString());
|
args.push('DIALECT', options.DIALECT.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options?.TIMEOUT !== undefined) {
|
||||||
|
args.push('TIMEOUT', options.TIMEOUT.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -233,6 +233,15 @@ describe('SEARCH', () => {
|
|||||||
['FT.SEARCH', 'index', 'query', 'DIALECT', '1']
|
['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', () => {
|
describe('client.ft.search', () => {
|
||||||
|
@@ -55,6 +55,7 @@ export interface SearchOptions {
|
|||||||
};
|
};
|
||||||
PARAMS?: Params;
|
PARAMS?: Params;
|
||||||
DIALECT?: number;
|
DIALECT?: number;
|
||||||
|
TIMEOUT?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformArguments(
|
export function transformArguments(
|
||||||
|
@@ -510,6 +510,10 @@ export function pushSearchOptions(
|
|||||||
args.preserve = true;
|
args.preserve = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options?.TIMEOUT !== undefined) {
|
||||||
|
args.push('TIMEOUT', options.TIMEOUT.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user