@redis/search 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -0
- package/dist/commands/AGGREGATE.d.ts +114 -0
- package/dist/commands/AGGREGATE.js +162 -0
- package/dist/commands/ALIASADD.d.ts +2 -0
- package/dist/commands/ALIASADD.js +7 -0
- package/dist/commands/ALIASDEL.d.ts +2 -0
- package/dist/commands/ALIASDEL.js +7 -0
- package/dist/commands/ALIASUPDATE.d.ts +2 -0
- package/dist/commands/ALIASUPDATE.js +7 -0
- package/dist/commands/ALTER.d.ts +3 -0
- package/dist/commands/ALTER.js +10 -0
- package/dist/commands/CONFIG_GET.d.ts +6 -0
- package/dist/commands/CONFIG_GET.js +15 -0
- package/dist/commands/CONFIG_SET.d.ts +2 -0
- package/dist/commands/CONFIG_SET.js +7 -0
- package/dist/commands/CREATE.d.ts +21 -0
- package/dist/commands/CREATE.js +56 -0
- package/dist/commands/DICTADD.d.ts +3 -0
- package/dist/commands/DICTADD.js +8 -0
- package/dist/commands/DICTDEL.d.ts +3 -0
- package/dist/commands/DICTDEL.js +8 -0
- package/dist/commands/DICTDUMP.d.ts +2 -0
- package/dist/commands/DICTDUMP.js +7 -0
- package/dist/commands/DROPINDEX.d.ts +6 -0
- package/dist/commands/DROPINDEX.js +11 -0
- package/dist/commands/EXPLAIN.d.ts +9 -0
- package/dist/commands/EXPLAIN.js +14 -0
- package/dist/commands/EXPLAINCLI.d.ts +3 -0
- package/dist/commands/EXPLAINCLI.js +8 -0
- package/dist/commands/INFO.d.ts +120 -0
- package/dist/commands/INFO.js +51 -0
- package/dist/commands/PROFILE_AGGREGATE.d.ts +7 -0
- package/dist/commands/PROFILE_AGGREGATE.js +23 -0
- package/dist/commands/PROFILE_SEARCH.d.ts +8 -0
- package/dist/commands/PROFILE_SEARCH.js +22 -0
- package/dist/commands/SEARCH.d.ts +40 -0
- package/dist/commands/SEARCH.js +28 -0
- package/dist/commands/SPELLCHECK.d.ts +24 -0
- package/dist/commands/SPELLCHECK.js +37 -0
- package/dist/commands/SUGADD.d.ts +7 -0
- package/dist/commands/SUGADD.js +14 -0
- package/dist/commands/SUGDEL.d.ts +2 -0
- package/dist/commands/SUGDEL.js +9 -0
- package/dist/commands/SUGGET.d.ts +7 -0
- package/dist/commands/SUGGET.js +15 -0
- package/dist/commands/SUGGET_WITHPAYLOADS.d.ts +8 -0
- package/dist/commands/SUGGET_WITHPAYLOADS.js +26 -0
- package/dist/commands/SUGGET_WITHSCORES.d.ts +8 -0
- package/dist/commands/SUGGET_WITHSCORES.js +26 -0
- package/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS.d.ts +7 -0
- package/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS.js +28 -0
- package/dist/commands/SUGLEN.d.ts +3 -0
- package/dist/commands/SUGLEN.js +8 -0
- package/dist/commands/SYNDUMP.d.ts +2 -0
- package/dist/commands/SYNDUMP.js +7 -0
- package/dist/commands/SYNUPDATE.d.ts +7 -0
- package/dist/commands/SYNUPDATE.js +12 -0
- package/dist/commands/TAGVALS.d.ts +2 -0
- package/dist/commands/TAGVALS.js +7 -0
- package/dist/commands/_LIST.d.ts +2 -0
- package/dist/commands/_LIST.js +7 -0
- package/dist/commands/index.d.ts +240 -0
- package/dist/commands/index.js +409 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/package.json +29 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import * as _LIST from './_LIST';
|
|
2
|
+
import * as ALTER from './ALTER';
|
|
3
|
+
import * as AGGREGATE from './AGGREGATE';
|
|
4
|
+
import * as ALIASADD from './ALIASADD';
|
|
5
|
+
import * as ALIASDEL from './ALIASDEL';
|
|
6
|
+
import * as ALIASUPDATE from './ALIASUPDATE';
|
|
7
|
+
import * as CONFIG_GET from './CONFIG_GET';
|
|
8
|
+
import * as CONFIG_SET from './CONFIG_SET';
|
|
9
|
+
import * as CREATE from './CREATE';
|
|
10
|
+
import * as DICTADD from './DICTADD';
|
|
11
|
+
import * as DICTDEL from './DICTDEL';
|
|
12
|
+
import * as DICTDUMP from './DICTDUMP';
|
|
13
|
+
import * as DROPINDEX from './DROPINDEX';
|
|
14
|
+
import * as EXPLAIN from './EXPLAIN';
|
|
15
|
+
import * as EXPLAINCLI from './EXPLAINCLI';
|
|
16
|
+
import * as INFO from './INFO';
|
|
17
|
+
import * as PROFILESEARCH from './PROFILE_SEARCH';
|
|
18
|
+
import * as PROFILEAGGREGATE from './PROFILE_AGGREGATE';
|
|
19
|
+
import * as SEARCH from './SEARCH';
|
|
20
|
+
import * as SPELLCHECK from './SPELLCHECK';
|
|
21
|
+
import * as SUGADD from './SUGADD';
|
|
22
|
+
import * as SUGDEL from './SUGDEL';
|
|
23
|
+
import * as SUGGET_WITHPAYLOADS from './SUGGET_WITHPAYLOADS';
|
|
24
|
+
import * as SUGGET_WITHSCORES_WITHPAYLOADS from './SUGGET_WITHSCORES_WITHPAYLOADS';
|
|
25
|
+
import * as SUGGET_WITHSCORES from './SUGGET_WITHSCORES';
|
|
26
|
+
import * as SUGGET from './SUGGET';
|
|
27
|
+
import * as SUGLEN from './SUGLEN';
|
|
28
|
+
import * as SYNDUMP from './SYNDUMP';
|
|
29
|
+
import * as SYNUPDATE from './SYNUPDATE';
|
|
30
|
+
import * as TAGVALS from './TAGVALS';
|
|
31
|
+
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
|
32
|
+
import { SearchOptions } from './SEARCH';
|
|
33
|
+
declare const _default: {
|
|
34
|
+
_LIST: typeof _LIST;
|
|
35
|
+
_list: typeof _LIST;
|
|
36
|
+
ALTER: typeof ALTER;
|
|
37
|
+
alter: typeof ALTER;
|
|
38
|
+
AGGREGATE: typeof AGGREGATE;
|
|
39
|
+
aggregate: typeof AGGREGATE;
|
|
40
|
+
ALIASADD: typeof ALIASADD;
|
|
41
|
+
aliasAdd: typeof ALIASADD;
|
|
42
|
+
ALIASDEL: typeof ALIASDEL;
|
|
43
|
+
aliasDel: typeof ALIASDEL;
|
|
44
|
+
ALIASUPDATE: typeof ALIASUPDATE;
|
|
45
|
+
aliasUpdate: typeof ALIASUPDATE;
|
|
46
|
+
CONFIG_GET: typeof CONFIG_GET;
|
|
47
|
+
configGet: typeof CONFIG_GET;
|
|
48
|
+
CONFIG_SET: typeof CONFIG_SET;
|
|
49
|
+
configSet: typeof CONFIG_SET;
|
|
50
|
+
CREATE: typeof CREATE;
|
|
51
|
+
create: typeof CREATE;
|
|
52
|
+
DICTADD: typeof DICTADD;
|
|
53
|
+
dictAdd: typeof DICTADD;
|
|
54
|
+
DICTDEL: typeof DICTDEL;
|
|
55
|
+
dictDel: typeof DICTDEL;
|
|
56
|
+
DICTDUMP: typeof DICTDUMP;
|
|
57
|
+
dictDump: typeof DICTDUMP;
|
|
58
|
+
DROPINDEX: typeof DROPINDEX;
|
|
59
|
+
dropIndex: typeof DROPINDEX;
|
|
60
|
+
EXPLAIN: typeof EXPLAIN;
|
|
61
|
+
explain: typeof EXPLAIN;
|
|
62
|
+
EXPLAINCLI: typeof EXPLAINCLI;
|
|
63
|
+
explainCli: typeof EXPLAINCLI;
|
|
64
|
+
INFO: typeof INFO;
|
|
65
|
+
info: typeof INFO;
|
|
66
|
+
PROFILESEARCH: typeof PROFILESEARCH;
|
|
67
|
+
profileSearch: typeof PROFILESEARCH;
|
|
68
|
+
PROFILEAGGREGATE: typeof PROFILEAGGREGATE;
|
|
69
|
+
profileAggregate: typeof PROFILEAGGREGATE;
|
|
70
|
+
SEARCH: typeof SEARCH;
|
|
71
|
+
search: typeof SEARCH;
|
|
72
|
+
SPELLCHECK: typeof SPELLCHECK;
|
|
73
|
+
spellCheck: typeof SPELLCHECK;
|
|
74
|
+
SUGADD: typeof SUGADD;
|
|
75
|
+
sugAdd: typeof SUGADD;
|
|
76
|
+
SUGDEL: typeof SUGDEL;
|
|
77
|
+
sugDel: typeof SUGDEL;
|
|
78
|
+
SUGGET_WITHPAYLOADS: typeof SUGGET_WITHPAYLOADS;
|
|
79
|
+
sugGetWithPayloads: typeof SUGGET_WITHPAYLOADS;
|
|
80
|
+
SUGGET_WITHSCORES_WITHPAYLOADS: typeof SUGGET_WITHSCORES_WITHPAYLOADS;
|
|
81
|
+
sugGetWithScoresWithPayloads: typeof SUGGET_WITHSCORES_WITHPAYLOADS;
|
|
82
|
+
SUGGET_WITHSCORES: typeof SUGGET_WITHSCORES;
|
|
83
|
+
sugGetWithScores: typeof SUGGET_WITHSCORES;
|
|
84
|
+
SUGGET: typeof SUGGET;
|
|
85
|
+
sugGet: typeof SUGGET;
|
|
86
|
+
SUGLEN: typeof SUGLEN;
|
|
87
|
+
sugLen: typeof SUGLEN;
|
|
88
|
+
SYNDUMP: typeof SYNDUMP;
|
|
89
|
+
synDump: typeof SYNDUMP;
|
|
90
|
+
SYNUPDATE: typeof SYNUPDATE;
|
|
91
|
+
synUpdate: typeof SYNUPDATE;
|
|
92
|
+
TAGVALS: typeof TAGVALS;
|
|
93
|
+
tagVals: typeof TAGVALS;
|
|
94
|
+
};
|
|
95
|
+
export default _default;
|
|
96
|
+
export declare enum RedisSearchLanguages {
|
|
97
|
+
ARABIC = "Arabic",
|
|
98
|
+
BASQUE = "Basque",
|
|
99
|
+
CATALANA = "Catalan",
|
|
100
|
+
DANISH = "Danish",
|
|
101
|
+
DUTCH = "Dutch",
|
|
102
|
+
ENGLISH = "English",
|
|
103
|
+
FINNISH = "Finnish",
|
|
104
|
+
FRENCH = "French",
|
|
105
|
+
GERMAN = "German",
|
|
106
|
+
GREEK = "Greek",
|
|
107
|
+
HUNGARIAN = "Hungarian",
|
|
108
|
+
INDONESAIN = "Indonesian",
|
|
109
|
+
IRISH = "Irish",
|
|
110
|
+
ITALIAN = "Italian",
|
|
111
|
+
LITHUANIAN = "Lithuanian",
|
|
112
|
+
NEPALI = "Nepali",
|
|
113
|
+
NORWEIGAN = "Norwegian",
|
|
114
|
+
PORTUGUESE = "Portuguese",
|
|
115
|
+
ROMANIAN = "Romanian",
|
|
116
|
+
RUSSIAN = "Russian",
|
|
117
|
+
SPANISH = "Spanish",
|
|
118
|
+
SWEDISH = "Swedish",
|
|
119
|
+
TAMIL = "Tamil",
|
|
120
|
+
TURKISH = "Turkish",
|
|
121
|
+
CHINESE = "Chinese"
|
|
122
|
+
}
|
|
123
|
+
export declare type PropertyName = `${'@' | '$.'}${string}`;
|
|
124
|
+
export declare type SortByProperty = PropertyName | {
|
|
125
|
+
BY: PropertyName;
|
|
126
|
+
DIRECTION?: 'ASC' | 'DESC';
|
|
127
|
+
};
|
|
128
|
+
export declare function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void;
|
|
129
|
+
export declare function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array<SortByProperty>): RedisCommandArguments;
|
|
130
|
+
export declare function pushArgumentsWithLength(args: RedisCommandArguments, fn: (args: RedisCommandArguments) => void): RedisCommandArguments;
|
|
131
|
+
export declare enum SchemaFieldTypes {
|
|
132
|
+
TEXT = "TEXT",
|
|
133
|
+
NUMERIC = "NUMERIC",
|
|
134
|
+
GEO = "GEO",
|
|
135
|
+
TAG = "TAG",
|
|
136
|
+
VECTOR = "VECTOR"
|
|
137
|
+
}
|
|
138
|
+
declare type CreateSchemaField<T extends SchemaFieldTypes, E = Record<keyof any, any>> = T | ({
|
|
139
|
+
type: T;
|
|
140
|
+
AS?: string;
|
|
141
|
+
} & E);
|
|
142
|
+
declare type CreateSchemaCommonField<T extends SchemaFieldTypes, E = Record<string, never>> = CreateSchemaField<T, ({
|
|
143
|
+
SORTABLE?: true | 'UNF';
|
|
144
|
+
NOINDEX?: true;
|
|
145
|
+
} & E)>;
|
|
146
|
+
export declare enum SchemaTextFieldPhonetics {
|
|
147
|
+
DM_EN = "dm:en",
|
|
148
|
+
DM_FR = "dm:fr",
|
|
149
|
+
FM_PT = "dm:pt",
|
|
150
|
+
DM_ES = "dm:es"
|
|
151
|
+
}
|
|
152
|
+
declare type CreateSchemaTextField = CreateSchemaCommonField<SchemaFieldTypes.TEXT, {
|
|
153
|
+
NOSTEM?: true;
|
|
154
|
+
WEIGHT?: number;
|
|
155
|
+
PHONETIC?: SchemaTextFieldPhonetics;
|
|
156
|
+
}>;
|
|
157
|
+
declare type CreateSchemaNumericField = CreateSchemaCommonField<SchemaFieldTypes.NUMERIC>;
|
|
158
|
+
declare type CreateSchemaGeoField = CreateSchemaCommonField<SchemaFieldTypes.GEO>;
|
|
159
|
+
declare type CreateSchemaTagField = CreateSchemaCommonField<SchemaFieldTypes.TAG, {
|
|
160
|
+
SEPARATOR?: string;
|
|
161
|
+
CASESENSITIVE?: true;
|
|
162
|
+
}>;
|
|
163
|
+
export declare enum VectorAlgorithms {
|
|
164
|
+
FLAT = "FLAT",
|
|
165
|
+
HNSW = "HNSW"
|
|
166
|
+
}
|
|
167
|
+
declare type CreateSchemaVectorField<T extends VectorAlgorithms, A extends Record<string, unknown>> = CreateSchemaField<SchemaFieldTypes.VECTOR, {
|
|
168
|
+
ALGORITHM: T;
|
|
169
|
+
TYPE: string;
|
|
170
|
+
DIM: number;
|
|
171
|
+
DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
|
|
172
|
+
INITIAL_CAP?: number;
|
|
173
|
+
} & A>;
|
|
174
|
+
declare type CreateSchemaFlatVectorField = CreateSchemaVectorField<VectorAlgorithms.FLAT, {
|
|
175
|
+
BLOCK_SIZE?: number;
|
|
176
|
+
}>;
|
|
177
|
+
declare type CreateSchemaHNSWVectorField = CreateSchemaVectorField<VectorAlgorithms.HNSW, {
|
|
178
|
+
M?: number;
|
|
179
|
+
EF_CONSTRUCTION?: number;
|
|
180
|
+
EF_RUNTIME?: number;
|
|
181
|
+
}>;
|
|
182
|
+
export interface RediSearchSchema {
|
|
183
|
+
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField | CreateSchemaFlatVectorField | CreateSchemaHNSWVectorField;
|
|
184
|
+
}
|
|
185
|
+
export declare function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema): void;
|
|
186
|
+
export declare type Params = Record<string, RedisCommandArgument | number>;
|
|
187
|
+
export declare function pushParamsArgs(args: RedisCommandArguments, params?: Params): RedisCommandArguments;
|
|
188
|
+
export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments;
|
|
189
|
+
interface SearchDocumentValue {
|
|
190
|
+
[key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue;
|
|
191
|
+
}
|
|
192
|
+
export interface SearchReply {
|
|
193
|
+
total: number;
|
|
194
|
+
documents: Array<{
|
|
195
|
+
id: string;
|
|
196
|
+
value: SearchDocumentValue;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
export interface ProfileOptions {
|
|
200
|
+
LIMITED?: true;
|
|
201
|
+
}
|
|
202
|
+
export declare type ProfileRawReply<T> = [
|
|
203
|
+
results: T,
|
|
204
|
+
profile: [
|
|
205
|
+
_: string,
|
|
206
|
+
TotalProfileTime: string,
|
|
207
|
+
_: string,
|
|
208
|
+
ParsingTime: string,
|
|
209
|
+
_: string,
|
|
210
|
+
PipelineCreationTime: string,
|
|
211
|
+
_: string,
|
|
212
|
+
IteratorsProfile: Array<any>
|
|
213
|
+
]
|
|
214
|
+
];
|
|
215
|
+
export interface ProfileReply {
|
|
216
|
+
results: SearchReply | AGGREGATE.AggregateReply;
|
|
217
|
+
profile: ProfileData;
|
|
218
|
+
}
|
|
219
|
+
interface ChildIterator {
|
|
220
|
+
type?: string;
|
|
221
|
+
counter?: number;
|
|
222
|
+
term?: string;
|
|
223
|
+
size?: number;
|
|
224
|
+
time?: string;
|
|
225
|
+
childIterators?: Array<ChildIterator>;
|
|
226
|
+
}
|
|
227
|
+
interface IteratorsProfile {
|
|
228
|
+
type?: string;
|
|
229
|
+
counter?: number;
|
|
230
|
+
queryType?: string;
|
|
231
|
+
time?: string;
|
|
232
|
+
childIterators?: Array<ChildIterator>;
|
|
233
|
+
}
|
|
234
|
+
interface ProfileData {
|
|
235
|
+
totalProfileTime: string;
|
|
236
|
+
parsingTime: string;
|
|
237
|
+
pipelineCreationTime: string;
|
|
238
|
+
iteratorsProfile: IteratorsProfile;
|
|
239
|
+
}
|
|
240
|
+
export declare function transformProfile(reply: Array<any>): ProfileData;
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformProfile = exports.pushSearchOptions = exports.pushParamsArgs = exports.pushSchema = exports.VectorAlgorithms = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.pushArgumentsWithLength = exports.pushSortByArguments = exports.pushSortByProperty = exports.RedisSearchLanguages = void 0;
|
|
4
|
+
const _LIST = require("./_LIST");
|
|
5
|
+
const ALTER = require("./ALTER");
|
|
6
|
+
const AGGREGATE = require("./AGGREGATE");
|
|
7
|
+
const ALIASADD = require("./ALIASADD");
|
|
8
|
+
const ALIASDEL = require("./ALIASDEL");
|
|
9
|
+
const ALIASUPDATE = require("./ALIASUPDATE");
|
|
10
|
+
const CONFIG_GET = require("./CONFIG_GET");
|
|
11
|
+
const CONFIG_SET = require("./CONFIG_SET");
|
|
12
|
+
const CREATE = require("./CREATE");
|
|
13
|
+
const DICTADD = require("./DICTADD");
|
|
14
|
+
const DICTDEL = require("./DICTDEL");
|
|
15
|
+
const DICTDUMP = require("./DICTDUMP");
|
|
16
|
+
const DROPINDEX = require("./DROPINDEX");
|
|
17
|
+
const EXPLAIN = require("./EXPLAIN");
|
|
18
|
+
const EXPLAINCLI = require("./EXPLAINCLI");
|
|
19
|
+
const INFO = require("./INFO");
|
|
20
|
+
const PROFILESEARCH = require("./PROFILE_SEARCH");
|
|
21
|
+
const PROFILEAGGREGATE = require("./PROFILE_AGGREGATE");
|
|
22
|
+
const SEARCH = require("./SEARCH");
|
|
23
|
+
const SPELLCHECK = require("./SPELLCHECK");
|
|
24
|
+
const SUGADD = require("./SUGADD");
|
|
25
|
+
const SUGDEL = require("./SUGDEL");
|
|
26
|
+
const SUGGET_WITHPAYLOADS = require("./SUGGET_WITHPAYLOADS");
|
|
27
|
+
const SUGGET_WITHSCORES_WITHPAYLOADS = require("./SUGGET_WITHSCORES_WITHPAYLOADS");
|
|
28
|
+
const SUGGET_WITHSCORES = require("./SUGGET_WITHSCORES");
|
|
29
|
+
const SUGGET = require("./SUGGET");
|
|
30
|
+
const SUGLEN = require("./SUGLEN");
|
|
31
|
+
const SYNDUMP = require("./SYNDUMP");
|
|
32
|
+
const SYNUPDATE = require("./SYNUPDATE");
|
|
33
|
+
const TAGVALS = require("./TAGVALS");
|
|
34
|
+
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
|
|
35
|
+
exports.default = {
|
|
36
|
+
_LIST,
|
|
37
|
+
_list: _LIST,
|
|
38
|
+
ALTER,
|
|
39
|
+
alter: ALTER,
|
|
40
|
+
AGGREGATE,
|
|
41
|
+
aggregate: AGGREGATE,
|
|
42
|
+
ALIASADD,
|
|
43
|
+
aliasAdd: ALIASADD,
|
|
44
|
+
ALIASDEL,
|
|
45
|
+
aliasDel: ALIASDEL,
|
|
46
|
+
ALIASUPDATE,
|
|
47
|
+
aliasUpdate: ALIASUPDATE,
|
|
48
|
+
CONFIG_GET,
|
|
49
|
+
configGet: CONFIG_GET,
|
|
50
|
+
CONFIG_SET,
|
|
51
|
+
configSet: CONFIG_SET,
|
|
52
|
+
CREATE,
|
|
53
|
+
create: CREATE,
|
|
54
|
+
DICTADD,
|
|
55
|
+
dictAdd: DICTADD,
|
|
56
|
+
DICTDEL,
|
|
57
|
+
dictDel: DICTDEL,
|
|
58
|
+
DICTDUMP,
|
|
59
|
+
dictDump: DICTDUMP,
|
|
60
|
+
DROPINDEX,
|
|
61
|
+
dropIndex: DROPINDEX,
|
|
62
|
+
EXPLAIN,
|
|
63
|
+
explain: EXPLAIN,
|
|
64
|
+
EXPLAINCLI,
|
|
65
|
+
explainCli: EXPLAINCLI,
|
|
66
|
+
INFO,
|
|
67
|
+
info: INFO,
|
|
68
|
+
PROFILESEARCH,
|
|
69
|
+
profileSearch: PROFILESEARCH,
|
|
70
|
+
PROFILEAGGREGATE,
|
|
71
|
+
profileAggregate: PROFILEAGGREGATE,
|
|
72
|
+
SEARCH,
|
|
73
|
+
search: SEARCH,
|
|
74
|
+
SPELLCHECK,
|
|
75
|
+
spellCheck: SPELLCHECK,
|
|
76
|
+
SUGADD,
|
|
77
|
+
sugAdd: SUGADD,
|
|
78
|
+
SUGDEL,
|
|
79
|
+
sugDel: SUGDEL,
|
|
80
|
+
SUGGET_WITHPAYLOADS,
|
|
81
|
+
sugGetWithPayloads: SUGGET_WITHPAYLOADS,
|
|
82
|
+
SUGGET_WITHSCORES_WITHPAYLOADS,
|
|
83
|
+
sugGetWithScoresWithPayloads: SUGGET_WITHSCORES_WITHPAYLOADS,
|
|
84
|
+
SUGGET_WITHSCORES,
|
|
85
|
+
sugGetWithScores: SUGGET_WITHSCORES,
|
|
86
|
+
SUGGET,
|
|
87
|
+
sugGet: SUGGET,
|
|
88
|
+
SUGLEN,
|
|
89
|
+
sugLen: SUGLEN,
|
|
90
|
+
SYNDUMP,
|
|
91
|
+
synDump: SYNDUMP,
|
|
92
|
+
SYNUPDATE,
|
|
93
|
+
synUpdate: SYNUPDATE,
|
|
94
|
+
TAGVALS,
|
|
95
|
+
tagVals: TAGVALS
|
|
96
|
+
};
|
|
97
|
+
var RedisSearchLanguages;
|
|
98
|
+
(function (RedisSearchLanguages) {
|
|
99
|
+
RedisSearchLanguages["ARABIC"] = "Arabic";
|
|
100
|
+
RedisSearchLanguages["BASQUE"] = "Basque";
|
|
101
|
+
RedisSearchLanguages["CATALANA"] = "Catalan";
|
|
102
|
+
RedisSearchLanguages["DANISH"] = "Danish";
|
|
103
|
+
RedisSearchLanguages["DUTCH"] = "Dutch";
|
|
104
|
+
RedisSearchLanguages["ENGLISH"] = "English";
|
|
105
|
+
RedisSearchLanguages["FINNISH"] = "Finnish";
|
|
106
|
+
RedisSearchLanguages["FRENCH"] = "French";
|
|
107
|
+
RedisSearchLanguages["GERMAN"] = "German";
|
|
108
|
+
RedisSearchLanguages["GREEK"] = "Greek";
|
|
109
|
+
RedisSearchLanguages["HUNGARIAN"] = "Hungarian";
|
|
110
|
+
RedisSearchLanguages["INDONESAIN"] = "Indonesian";
|
|
111
|
+
RedisSearchLanguages["IRISH"] = "Irish";
|
|
112
|
+
RedisSearchLanguages["ITALIAN"] = "Italian";
|
|
113
|
+
RedisSearchLanguages["LITHUANIAN"] = "Lithuanian";
|
|
114
|
+
RedisSearchLanguages["NEPALI"] = "Nepali";
|
|
115
|
+
RedisSearchLanguages["NORWEIGAN"] = "Norwegian";
|
|
116
|
+
RedisSearchLanguages["PORTUGUESE"] = "Portuguese";
|
|
117
|
+
RedisSearchLanguages["ROMANIAN"] = "Romanian";
|
|
118
|
+
RedisSearchLanguages["RUSSIAN"] = "Russian";
|
|
119
|
+
RedisSearchLanguages["SPANISH"] = "Spanish";
|
|
120
|
+
RedisSearchLanguages["SWEDISH"] = "Swedish";
|
|
121
|
+
RedisSearchLanguages["TAMIL"] = "Tamil";
|
|
122
|
+
RedisSearchLanguages["TURKISH"] = "Turkish";
|
|
123
|
+
RedisSearchLanguages["CHINESE"] = "Chinese";
|
|
124
|
+
})(RedisSearchLanguages = exports.RedisSearchLanguages || (exports.RedisSearchLanguages = {}));
|
|
125
|
+
function pushSortByProperty(args, sortBy) {
|
|
126
|
+
if (typeof sortBy === 'string') {
|
|
127
|
+
args.push(sortBy);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
args.push(sortBy.BY);
|
|
131
|
+
if (sortBy.DIRECTION) {
|
|
132
|
+
args.push(sortBy.DIRECTION);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.pushSortByProperty = pushSortByProperty;
|
|
137
|
+
function pushSortByArguments(args, name, sortBy) {
|
|
138
|
+
const lengthBefore = args.push(name, '' // will be overwritten
|
|
139
|
+
);
|
|
140
|
+
if (Array.isArray(sortBy)) {
|
|
141
|
+
for (const field of sortBy) {
|
|
142
|
+
pushSortByProperty(args, field);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
pushSortByProperty(args, sortBy);
|
|
147
|
+
}
|
|
148
|
+
args[lengthBefore - 1] = (args.length - lengthBefore).toString();
|
|
149
|
+
return args;
|
|
150
|
+
}
|
|
151
|
+
exports.pushSortByArguments = pushSortByArguments;
|
|
152
|
+
function pushArgumentsWithLength(args, fn) {
|
|
153
|
+
const lengthIndex = args.push('') - 1;
|
|
154
|
+
fn(args);
|
|
155
|
+
args[lengthIndex] = (args.length - lengthIndex - 1).toString();
|
|
156
|
+
return args;
|
|
157
|
+
}
|
|
158
|
+
exports.pushArgumentsWithLength = pushArgumentsWithLength;
|
|
159
|
+
var SchemaFieldTypes;
|
|
160
|
+
(function (SchemaFieldTypes) {
|
|
161
|
+
SchemaFieldTypes["TEXT"] = "TEXT";
|
|
162
|
+
SchemaFieldTypes["NUMERIC"] = "NUMERIC";
|
|
163
|
+
SchemaFieldTypes["GEO"] = "GEO";
|
|
164
|
+
SchemaFieldTypes["TAG"] = "TAG";
|
|
165
|
+
SchemaFieldTypes["VECTOR"] = "VECTOR";
|
|
166
|
+
})(SchemaFieldTypes = exports.SchemaFieldTypes || (exports.SchemaFieldTypes = {}));
|
|
167
|
+
var SchemaTextFieldPhonetics;
|
|
168
|
+
(function (SchemaTextFieldPhonetics) {
|
|
169
|
+
SchemaTextFieldPhonetics["DM_EN"] = "dm:en";
|
|
170
|
+
SchemaTextFieldPhonetics["DM_FR"] = "dm:fr";
|
|
171
|
+
SchemaTextFieldPhonetics["FM_PT"] = "dm:pt";
|
|
172
|
+
SchemaTextFieldPhonetics["DM_ES"] = "dm:es";
|
|
173
|
+
})(SchemaTextFieldPhonetics = exports.SchemaTextFieldPhonetics || (exports.SchemaTextFieldPhonetics = {}));
|
|
174
|
+
var VectorAlgorithms;
|
|
175
|
+
(function (VectorAlgorithms) {
|
|
176
|
+
VectorAlgorithms["FLAT"] = "FLAT";
|
|
177
|
+
VectorAlgorithms["HNSW"] = "HNSW";
|
|
178
|
+
})(VectorAlgorithms = exports.VectorAlgorithms || (exports.VectorAlgorithms = {}));
|
|
179
|
+
function pushSchema(args, schema) {
|
|
180
|
+
for (const [field, fieldOptions] of Object.entries(schema)) {
|
|
181
|
+
args.push(field);
|
|
182
|
+
if (typeof fieldOptions === 'string') {
|
|
183
|
+
args.push(fieldOptions);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (fieldOptions.AS) {
|
|
187
|
+
args.push('AS', fieldOptions.AS);
|
|
188
|
+
}
|
|
189
|
+
args.push(fieldOptions.type);
|
|
190
|
+
switch (fieldOptions.type) {
|
|
191
|
+
case SchemaFieldTypes.TEXT:
|
|
192
|
+
if (fieldOptions.NOSTEM) {
|
|
193
|
+
args.push('NOSTEM');
|
|
194
|
+
}
|
|
195
|
+
if (fieldOptions.WEIGHT) {
|
|
196
|
+
args.push('WEIGHT', fieldOptions.WEIGHT.toString());
|
|
197
|
+
}
|
|
198
|
+
if (fieldOptions.PHONETIC) {
|
|
199
|
+
args.push('PHONETIC', fieldOptions.PHONETIC);
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
// case SchemaFieldTypes.NUMERIC:
|
|
203
|
+
// case SchemaFieldTypes.GEO:
|
|
204
|
+
// break;
|
|
205
|
+
case SchemaFieldTypes.TAG:
|
|
206
|
+
if (fieldOptions.SEPARATOR) {
|
|
207
|
+
args.push('SEPARATOR', fieldOptions.SEPARATOR);
|
|
208
|
+
}
|
|
209
|
+
if (fieldOptions.CASESENSITIVE) {
|
|
210
|
+
args.push('CASESENSITIVE');
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case SchemaFieldTypes.VECTOR:
|
|
214
|
+
args.push(fieldOptions.ALGORITHM);
|
|
215
|
+
pushArgumentsWithLength(args, () => {
|
|
216
|
+
args.push('TYPE', fieldOptions.TYPE, 'DIM', fieldOptions.DIM.toString(), 'DISTANCE_METRIC', fieldOptions.DISTANCE_METRIC);
|
|
217
|
+
if (fieldOptions.INITIAL_CAP) {
|
|
218
|
+
args.push('INITIAL_CAP', fieldOptions.INITIAL_CAP.toString());
|
|
219
|
+
}
|
|
220
|
+
switch (fieldOptions.ALGORITHM) {
|
|
221
|
+
case VectorAlgorithms.FLAT:
|
|
222
|
+
if (fieldOptions.BLOCK_SIZE) {
|
|
223
|
+
args.push('BLOCK_SIZE', fieldOptions.BLOCK_SIZE.toString());
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case VectorAlgorithms.HNSW:
|
|
227
|
+
if (fieldOptions.M) {
|
|
228
|
+
args.push('M', fieldOptions.M.toString());
|
|
229
|
+
}
|
|
230
|
+
if (fieldOptions.EF_CONSTRUCTION) {
|
|
231
|
+
args.push('EF_CONSTRUCTION', fieldOptions.EF_CONSTRUCTION.toString());
|
|
232
|
+
}
|
|
233
|
+
if (fieldOptions.EF_RUNTIME) {
|
|
234
|
+
args.push('EF_RUNTIME', fieldOptions.EF_RUNTIME.toString());
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
continue; // vector fields do not contain SORTABLE and NOINDEX options
|
|
240
|
+
}
|
|
241
|
+
if (fieldOptions.SORTABLE) {
|
|
242
|
+
args.push('SORTABLE');
|
|
243
|
+
if (fieldOptions.SORTABLE === 'UNF') {
|
|
244
|
+
args.push('UNF');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (fieldOptions.NOINDEX) {
|
|
248
|
+
args.push('NOINDEX');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
exports.pushSchema = pushSchema;
|
|
253
|
+
function pushParamsArgs(args, params) {
|
|
254
|
+
if (params) {
|
|
255
|
+
const enrties = Object.entries(params);
|
|
256
|
+
args.push('PARAMS', (enrties.length * 2).toString());
|
|
257
|
+
for (const [key, value] of enrties) {
|
|
258
|
+
args.push(key, typeof value === 'number' ? value.toString() : value);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return args;
|
|
262
|
+
}
|
|
263
|
+
exports.pushParamsArgs = pushParamsArgs;
|
|
264
|
+
function pushSearchOptions(args, options) {
|
|
265
|
+
if (options?.VERBATIM) {
|
|
266
|
+
args.push('VERBATIM');
|
|
267
|
+
}
|
|
268
|
+
if (options?.NOSTOPWORDS) {
|
|
269
|
+
args.push('NOSTOPWORDS');
|
|
270
|
+
}
|
|
271
|
+
// if (options?.WITHSCORES) {
|
|
272
|
+
// args.push('WITHSCORES');
|
|
273
|
+
// }
|
|
274
|
+
// if (options?.WITHPAYLOADS) {
|
|
275
|
+
// args.push('WITHPAYLOADS');
|
|
276
|
+
// }
|
|
277
|
+
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INKEYS', options?.INKEYS);
|
|
278
|
+
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INFIELDS', options?.INFIELDS);
|
|
279
|
+
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'RETURN', options?.RETURN);
|
|
280
|
+
if (options?.SUMMARIZE) {
|
|
281
|
+
args.push('SUMMARIZE');
|
|
282
|
+
if (typeof options.SUMMARIZE === 'object') {
|
|
283
|
+
if (options.SUMMARIZE.FIELDS) {
|
|
284
|
+
args.push('FIELDS');
|
|
285
|
+
(0, generic_transformers_1.pushVerdictArgument)(args, options.SUMMARIZE.FIELDS);
|
|
286
|
+
}
|
|
287
|
+
if (options.SUMMARIZE.FRAGS) {
|
|
288
|
+
args.push('FRAGS', options.SUMMARIZE.FRAGS.toString());
|
|
289
|
+
}
|
|
290
|
+
if (options.SUMMARIZE.LEN) {
|
|
291
|
+
args.push('LEN', options.SUMMARIZE.LEN.toString());
|
|
292
|
+
}
|
|
293
|
+
if (options.SUMMARIZE.SEPARATOR) {
|
|
294
|
+
args.push('SEPARATOR', options.SUMMARIZE.SEPARATOR);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (options?.HIGHLIGHT) {
|
|
299
|
+
args.push('HIGHLIGHT');
|
|
300
|
+
if (typeof options.HIGHLIGHT === 'object') {
|
|
301
|
+
if (options.HIGHLIGHT.FIELDS) {
|
|
302
|
+
args.push('FIELDS');
|
|
303
|
+
(0, generic_transformers_1.pushVerdictArgument)(args, options.HIGHLIGHT.FIELDS);
|
|
304
|
+
}
|
|
305
|
+
if (options.HIGHLIGHT.TAGS) {
|
|
306
|
+
args.push('TAGS', options.HIGHLIGHT.TAGS.open, options.HIGHLIGHT.TAGS.close);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (options?.SLOP) {
|
|
311
|
+
args.push('SLOP', options.SLOP.toString());
|
|
312
|
+
}
|
|
313
|
+
if (options?.INORDER) {
|
|
314
|
+
args.push('INORDER');
|
|
315
|
+
}
|
|
316
|
+
if (options?.LANGUAGE) {
|
|
317
|
+
args.push('LANGUAGE', options.LANGUAGE);
|
|
318
|
+
}
|
|
319
|
+
if (options?.EXPANDER) {
|
|
320
|
+
args.push('EXPANDER', options.EXPANDER);
|
|
321
|
+
}
|
|
322
|
+
if (options?.SCORER) {
|
|
323
|
+
args.push('SCORER', options.SCORER);
|
|
324
|
+
}
|
|
325
|
+
// if (options?.EXPLAINSCORE) {
|
|
326
|
+
// args.push('EXPLAINSCORE');
|
|
327
|
+
// }
|
|
328
|
+
// if (options?.PAYLOAD) {
|
|
329
|
+
// args.push('PAYLOAD', options.PAYLOAD);
|
|
330
|
+
// }
|
|
331
|
+
if (options?.SORTBY) {
|
|
332
|
+
args.push('SORTBY');
|
|
333
|
+
pushSortByProperty(args, options.SORTBY);
|
|
334
|
+
}
|
|
335
|
+
// if (options?.MSORTBY) {
|
|
336
|
+
// pushSortByArguments(args, 'MSORTBY', options.MSORTBY);
|
|
337
|
+
// }
|
|
338
|
+
if (options?.LIMIT) {
|
|
339
|
+
args.push('LIMIT', options.LIMIT.from.toString(), options.LIMIT.size.toString());
|
|
340
|
+
}
|
|
341
|
+
if (options?.PARAMS) {
|
|
342
|
+
pushParamsArgs(args, options.PARAMS);
|
|
343
|
+
}
|
|
344
|
+
if (options?.DIALECT) {
|
|
345
|
+
args.push('DIALECT', options.DIALECT.toString());
|
|
346
|
+
}
|
|
347
|
+
return args;
|
|
348
|
+
}
|
|
349
|
+
exports.pushSearchOptions = pushSearchOptions;
|
|
350
|
+
function transformProfile(reply) {
|
|
351
|
+
return {
|
|
352
|
+
totalProfileTime: reply[0][1],
|
|
353
|
+
parsingTime: reply[1][1],
|
|
354
|
+
pipelineCreationTime: reply[2][1],
|
|
355
|
+
iteratorsProfile: transformIterators(reply[3][1])
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
exports.transformProfile = transformProfile;
|
|
359
|
+
function transformIterators(IteratorsProfile) {
|
|
360
|
+
var res = {};
|
|
361
|
+
for (let i = 0; i < IteratorsProfile.length; i += 2) {
|
|
362
|
+
const value = IteratorsProfile[i + 1];
|
|
363
|
+
switch (IteratorsProfile[i]) {
|
|
364
|
+
case 'Type':
|
|
365
|
+
res.type = value;
|
|
366
|
+
break;
|
|
367
|
+
case 'Counter':
|
|
368
|
+
res.counter = value;
|
|
369
|
+
break;
|
|
370
|
+
case 'Time':
|
|
371
|
+
res.time = value;
|
|
372
|
+
break;
|
|
373
|
+
case 'Query type':
|
|
374
|
+
res.queryType = value;
|
|
375
|
+
break;
|
|
376
|
+
case 'Child iterators':
|
|
377
|
+
res.childIterators = value.map(transformChildIterators);
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return res;
|
|
382
|
+
}
|
|
383
|
+
function transformChildIterators(IteratorsProfile) {
|
|
384
|
+
var res = {};
|
|
385
|
+
for (let i = 1; i < IteratorsProfile.length; i += 2) {
|
|
386
|
+
const value = IteratorsProfile[i + 1];
|
|
387
|
+
switch (IteratorsProfile[i]) {
|
|
388
|
+
case 'Type':
|
|
389
|
+
res.type = value;
|
|
390
|
+
break;
|
|
391
|
+
case 'Counter':
|
|
392
|
+
res.counter = value;
|
|
393
|
+
break;
|
|
394
|
+
case 'Time':
|
|
395
|
+
res.time = value;
|
|
396
|
+
break;
|
|
397
|
+
case 'Size':
|
|
398
|
+
res.size = value;
|
|
399
|
+
break;
|
|
400
|
+
case 'Term':
|
|
401
|
+
res.term = value;
|
|
402
|
+
break;
|
|
403
|
+
case 'Child iterators':
|
|
404
|
+
res.childIterators = value.map(transformChildIterators);
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return res;
|
|
409
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default } from './commands';
|
|
2
|
+
export { RediSearchSchema, SchemaFieldTypes, SchemaTextFieldPhonetics, SearchReply, VectorAlgorithms } from './commands';
|
|
3
|
+
export { AggregateSteps, AggregateGroupByReducers } from './commands/AGGREGATE';
|
|
4
|
+
export { SearchOptions } from './commands/SEARCH';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AggregateGroupByReducers = exports.AggregateSteps = exports.VectorAlgorithms = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.default = void 0;
|
|
4
|
+
var commands_1 = require("./commands");
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return commands_1.default; } });
|
|
6
|
+
var commands_2 = require("./commands");
|
|
7
|
+
Object.defineProperty(exports, "SchemaFieldTypes", { enumerable: true, get: function () { return commands_2.SchemaFieldTypes; } });
|
|
8
|
+
Object.defineProperty(exports, "SchemaTextFieldPhonetics", { enumerable: true, get: function () { return commands_2.SchemaTextFieldPhonetics; } });
|
|
9
|
+
Object.defineProperty(exports, "VectorAlgorithms", { enumerable: true, get: function () { return commands_2.VectorAlgorithms; } });
|
|
10
|
+
var AGGREGATE_1 = require("./commands/AGGREGATE");
|
|
11
|
+
Object.defineProperty(exports, "AggregateSteps", { enumerable: true, get: function () { return AGGREGATE_1.AggregateSteps; } });
|
|
12
|
+
Object.defineProperty(exports, "AggregateGroupByReducers", { enumerable: true, get: function () { return AGGREGATE_1.AggregateGroupByReducers; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@redis/search",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "nyc -r text-summary -r lcov mocha -r source-map-support/register -r ts-node/register './lib/**/*.spec.ts'",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"documentation": "typedoc"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@redis/client": "^1.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
20
|
+
"@redis/test-utils": "*",
|
|
21
|
+
"@types/node": "^17.0.31",
|
|
22
|
+
"nyc": "^15.1.0",
|
|
23
|
+
"release-it": "^15.0.0",
|
|
24
|
+
"source-map-support": "^0.5.21",
|
|
25
|
+
"ts-node": "^10.7.0",
|
|
26
|
+
"typedoc": "^0.22.15",
|
|
27
|
+
"typescript": "^4.6.4"
|
|
28
|
+
}
|
|
29
|
+
}
|