From cba0289ff70acbf106a74ff2524260459ff59b9f Mon Sep 17 00:00:00 2001 From: leibale Date: Tue, 30 Nov 2021 21:34:37 -0500 Subject: [PATCH] fix FT.SEARCH --- packages/search/lib/commands/AGGREGATE.ts | 4 ++-- packages/search/lib/commands/SEARCH.ts | 6 +++--- packages/search/lib/commands/index.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/search/lib/commands/AGGREGATE.ts b/packages/search/lib/commands/AGGREGATE.ts index c81dcfef4d..2546618890 100644 --- a/packages/search/lib/commands/AGGREGATE.ts +++ b/packages/search/lib/commands/AGGREGATE.ts @@ -1,6 +1,6 @@ import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands'; import { pushVerdictArgument, transformReplyTuples, TuplesObject } from '@node-redis/client/dist/lib/commands/generic-transformers'; -import { PropertyName, pushArgumentsWithLength, pushSortByArguments, SortByOptions } from '.'; +import { PropertyName, pushArgumentsWithLength, pushSortByArguments, SortByProperty } from '.'; export enum AggregateSteps { GROUPBY = 'GROUPBY', @@ -95,7 +95,7 @@ interface GroupByStep extends AggregateStep { } interface SortStep extends AggregateStep { - BY: SortByOptions | Array; + BY: SortByProperty | Array; MAX?: number; } diff --git a/packages/search/lib/commands/SEARCH.ts b/packages/search/lib/commands/SEARCH.ts index 0202d41de8..34d255e5b2 100644 --- a/packages/search/lib/commands/SEARCH.ts +++ b/packages/search/lib/commands/SEARCH.ts @@ -1,6 +1,6 @@ import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands'; import { pushOptionalVerdictArgument, pushVerdictArgument, transformReplyTuples } from '@node-redis/client/dist/lib/commands/generic-transformers'; -import { RedisSearchLanguages, PropertyName, pushSortByProperty, SortByOptions } from '.'; +import { RedisSearchLanguages, PropertyName, pushSortByProperty, SortByProperty } from '.'; export const FIRST_KEY_INDEX = 1; @@ -48,8 +48,8 @@ interface SearchOptions { SCORER?: string; // EXPLAINSCORE?: true; // TODO: WITHSCORES // PAYLOAD?: ; - SORTBY?: SortByOptions; - // MSORTBY?: SortByOptions | Array; + SORTBY?: SortByProperty; + // MSORTBY?: SortByProperty | Array; LIMIT?: { from: number | string; size: number | string; diff --git a/packages/search/lib/commands/index.ts b/packages/search/lib/commands/index.ts index 70626c00df..d7b2b79343 100644 --- a/packages/search/lib/commands/index.ts +++ b/packages/search/lib/commands/index.ts @@ -117,12 +117,12 @@ export enum RedisSearchLanguages { export type PropertyName = `${'@' | '$.'}${string}`; -export type SortByOptions = PropertyName | { +export type SortByProperty = PropertyName | { BY: PropertyName; DIRECTION?: 'ASC' | 'DESC'; }; -function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByOptions): void { +export function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void { if (typeof sortBy === 'string') { args.push(sortBy); } else { @@ -134,7 +134,7 @@ function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByOptions): } } -export function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByOptions | Array): RedisCommandArguments { +export function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array): RedisCommandArguments { const lengthBefore = args.push( name, '' // will be overwritten