| 1 |
import { SearchOptions, SearchRawReply, transformReply as transformSearchReply } from './SEARCH'; |
| 2 |
import { pushSearchOptions, ProfileOptions, ProfileRawReply, ProfileReply, transformProfile } from '.'; |
| 3 |
import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; |
| 4 |
|
| 5 |
export const IS_READ_ONLY = true; |
| 6 |
|
| 7 |
export function transformArguments( |
| 8 |
index: string, |
| 9 |
query: string, |
| 10 |
options?: ProfileOptions & SearchOptions |
| 11 |
): RedisCommandArguments { |
| 12 |
let args: RedisCommandArguments = ['FT.PROFILE', index, 'SEARCH']; |
| 13 |
|
| 14 |
if (options?.LIMITED) { |
| 15 |
args.push('LIMITED'); |
| 16 |
} |
| 17 |
|
| 18 |
args.push('QUERY', query); |
| 19 |
return pushSearchOptions(args, options); |
| 20 |
} |
| 21 |
|
| 22 |
type ProfileSearchRawReply = ProfileRawReply<SearchRawReply>; |
| 23 |
|
| 24 |
export function transformReply(reply: ProfileSearchRawReply, withoutDocuments: boolean): ProfileReply { |
| 25 |
return { |
| 26 |
results: transformSearchReply(reply[0], withoutDocuments), |
| 27 |
profile: transformProfile(reply[1]) |
| 28 |
}; |
| 29 |
} |