Skip to content

Commit c21dd92

Browse files
authored
fix(search): adjust field types for ft.search (#3018)
In ft.search SORTBY, SUMMARIZE and HIGHLIGHT all take string arguments and do not need @ or $ as a prefix. In fact, if you put @ or $ there, redis returns error like this: [SimpleError: Property `@age` not loaded nor in schema] fixes #3017
1 parent 987515c commit c21dd92

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/search/lib/commands/SEARCH.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CommandParser } from '@redis/client/dist/lib/client/parser';
22
import { RedisArgument, Command, ReplyUnion } from '@redis/client/dist/lib/RESP/types';
33
import { RedisVariadicArgument, parseOptionalVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
4-
import { RediSearchProperty, RediSearchLanguage } from './CREATE';
4+
import { RediSearchLanguage } from './CREATE';
55
import { DEFAULT_DIALECT } from '../dialect/default';
66

77
export type FtSearchParams = Record<string, RedisArgument | number>;
@@ -32,13 +32,13 @@ export interface FtSearchOptions {
3232
INFIELDS?: RedisVariadicArgument;
3333
RETURN?: RedisVariadicArgument;
3434
SUMMARIZE?: boolean | {
35-
FIELDS?: RediSearchProperty | Array<RediSearchProperty>;
35+
FIELDS?: RedisArgument | Array<RedisArgument>;
3636
FRAGS?: number;
3737
LEN?: number;
3838
SEPARATOR?: RedisArgument;
3939
};
4040
HIGHLIGHT?: boolean | {
41-
FIELDS?: RediSearchProperty | Array<RediSearchProperty>;
41+
FIELDS?: RedisArgument | Array<RedisArgument>;
4242
TAGS?: {
4343
open: RedisArgument;
4444
close: RedisArgument;
@@ -51,7 +51,7 @@ export interface FtSearchOptions {
5151
EXPANDER?: RedisArgument;
5252
SCORER?: RedisArgument;
5353
SORTBY?: RedisArgument | {
54-
BY: RediSearchProperty;
54+
BY: RedisArgument;
5555
DIRECTION?: 'ASC' | 'DESC';
5656
};
5757
LIMIT?: {
@@ -133,7 +133,7 @@ export function parseSearchOptions(parser: CommandParser, options?: FtSearchOpti
133133

134134
if (options?.SORTBY) {
135135
parser.push('SORTBY');
136-
136+
137137
if (typeof options.SORTBY === 'string' || options.SORTBY instanceof Buffer) {
138138
parser.push(options.SORTBY);
139139
} else {
@@ -193,7 +193,7 @@ export default {
193193
value: withoutDocuments ? Object.create(null) : documentValue(reply[i++])
194194
});
195195
}
196-
196+
197197
return {
198198
total: reply[0],
199199
documents

0 commit comments

Comments
 (0)