Debian Codegraph @

packages/search/lib/commands/PROFILE_AGGREGATE.ts

raw
1 import { pushAggregatehOptions, AggregateOptions, transformReply as transformAggregateReply, AggregateRawReply } from './AGGREGATE';
2 import { ProfileOptions, ProfileRawReply, ProfileReply, transformProfile } from '.';
3
4 export const IS_READ_ONLY = true;
5
6 export function transformArguments(
7 index: string,
8 query: string,
9 options?: ProfileOptions & AggregateOptions
10 ): Array<string> {
11 const args = ['FT.PROFILE', index, 'AGGREGATE'];
12
13 if (options?.LIMITED) {
14 args.push('LIMITED');
15 }
16
17 args.push('QUERY', query);
18 pushAggregatehOptions(args, options)
19 return args;
20 }
21
22 type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;
23
24 export function transformReply(reply: ProfileAggeregateRawReply): ProfileReply {
25 return {
26 results: transformAggregateReply(reply[0]),
27 profile: transformProfile(reply[1])
28 };
29 }