You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
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
This commit is contained in:
committed by
GitHub
parent
987515c69b
commit
c21dd924fe
@@ -1,7 +1,7 @@
|
|||||||
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
||||||
import { RedisArgument, Command, ReplyUnion } from '@redis/client/dist/lib/RESP/types';
|
import { RedisArgument, Command, ReplyUnion } from '@redis/client/dist/lib/RESP/types';
|
||||||
import { RedisVariadicArgument, parseOptionalVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisVariadicArgument, parseOptionalVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||||
import { RediSearchProperty, RediSearchLanguage } from './CREATE';
|
import { RediSearchLanguage } from './CREATE';
|
||||||
import { DEFAULT_DIALECT } from '../dialect/default';
|
import { DEFAULT_DIALECT } from '../dialect/default';
|
||||||
|
|
||||||
export type FtSearchParams = Record<string, RedisArgument | number>;
|
export type FtSearchParams = Record<string, RedisArgument | number>;
|
||||||
@@ -32,13 +32,13 @@ export interface FtSearchOptions {
|
|||||||
INFIELDS?: RedisVariadicArgument;
|
INFIELDS?: RedisVariadicArgument;
|
||||||
RETURN?: RedisVariadicArgument;
|
RETURN?: RedisVariadicArgument;
|
||||||
SUMMARIZE?: boolean | {
|
SUMMARIZE?: boolean | {
|
||||||
FIELDS?: RediSearchProperty | Array<RediSearchProperty>;
|
FIELDS?: RedisArgument | Array<RedisArgument>;
|
||||||
FRAGS?: number;
|
FRAGS?: number;
|
||||||
LEN?: number;
|
LEN?: number;
|
||||||
SEPARATOR?: RedisArgument;
|
SEPARATOR?: RedisArgument;
|
||||||
};
|
};
|
||||||
HIGHLIGHT?: boolean | {
|
HIGHLIGHT?: boolean | {
|
||||||
FIELDS?: RediSearchProperty | Array<RediSearchProperty>;
|
FIELDS?: RedisArgument | Array<RedisArgument>;
|
||||||
TAGS?: {
|
TAGS?: {
|
||||||
open: RedisArgument;
|
open: RedisArgument;
|
||||||
close: RedisArgument;
|
close: RedisArgument;
|
||||||
@@ -51,7 +51,7 @@ export interface FtSearchOptions {
|
|||||||
EXPANDER?: RedisArgument;
|
EXPANDER?: RedisArgument;
|
||||||
SCORER?: RedisArgument;
|
SCORER?: RedisArgument;
|
||||||
SORTBY?: RedisArgument | {
|
SORTBY?: RedisArgument | {
|
||||||
BY: RediSearchProperty;
|
BY: RedisArgument;
|
||||||
DIRECTION?: 'ASC' | 'DESC';
|
DIRECTION?: 'ASC' | 'DESC';
|
||||||
};
|
};
|
||||||
LIMIT?: {
|
LIMIT?: {
|
||||||
@@ -133,7 +133,7 @@ export function parseSearchOptions(parser: CommandParser, options?: FtSearchOpti
|
|||||||
|
|
||||||
if (options?.SORTBY) {
|
if (options?.SORTBY) {
|
||||||
parser.push('SORTBY');
|
parser.push('SORTBY');
|
||||||
|
|
||||||
if (typeof options.SORTBY === 'string' || options.SORTBY instanceof Buffer) {
|
if (typeof options.SORTBY === 'string' || options.SORTBY instanceof Buffer) {
|
||||||
parser.push(options.SORTBY);
|
parser.push(options.SORTBY);
|
||||||
} else {
|
} else {
|
||||||
@@ -193,7 +193,7 @@ export default {
|
|||||||
value: withoutDocuments ? Object.create(null) : documentValue(reply[i++])
|
value: withoutDocuments ? Object.create(null) : documentValue(reply[i++])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
total: reply[0],
|
total: reply[0],
|
||||||
documents
|
documents
|
||||||
|
Reference in New Issue
Block a user