@valkey/valkey-glide 2.3.1 → 2.4.0-rc2
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/build-ts/BaseClient.d.ts +146 -3
- package/build-ts/BaseClient.js +154 -3
- package/build-ts/ClientSideCache.d.ts +113 -0
- package/build-ts/ClientSideCache.js +103 -0
- package/build-ts/CompressionConfiguration.d.ts +69 -0
- package/build-ts/CompressionConfiguration.js +65 -0
- package/build-ts/EvictionPolicy.d.ts +21 -0
- package/build-ts/EvictionPolicy.js +25 -0
- package/build-ts/GlideClient.d.ts +9 -1
- package/build-ts/GlideClient.js +4 -0
- package/build-ts/GlideClusterClient.d.ts +2 -0
- package/build-ts/ProtobufMessage.d.ts +212 -2
- package/build-ts/ProtobufMessage.js +686 -103
- package/build-ts/index.d.ts +3 -0
- package/build-ts/index.js +3 -0
- package/build-ts/server-modules/GlideFt.d.ts +51 -2
- package/build-ts/server-modules/GlideFt.js +180 -8
- package/build-ts/server-modules/GlideFtOptions.d.ts +106 -8
- package/package.json +7 -7
package/build-ts/index.d.ts
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
export * from "../build-ts/native";
|
|
9
9
|
export * from "./BaseClient.js";
|
|
10
10
|
export * from "./Batch.js";
|
|
11
|
+
export * from "./ClientSideCache.js";
|
|
11
12
|
export * from "./Commands.js";
|
|
13
|
+
export * from "./CompressionConfiguration.js";
|
|
12
14
|
export * from "./Errors.js";
|
|
15
|
+
export * from "./EvictionPolicy.js";
|
|
13
16
|
export * from "./GlideClient.js";
|
|
14
17
|
export * from "./GlideClusterClient.js";
|
|
15
18
|
export * from "./Logger.js";
|
package/build-ts/index.js
CHANGED
|
@@ -25,8 +25,11 @@ __exportStar(require("../build-ts/native"), exports);
|
|
|
25
25
|
// Export TypeScript APIs
|
|
26
26
|
__exportStar(require("./BaseClient.js"), exports);
|
|
27
27
|
__exportStar(require("./Batch.js"), exports);
|
|
28
|
+
__exportStar(require("./ClientSideCache.js"), exports);
|
|
28
29
|
__exportStar(require("./Commands.js"), exports);
|
|
30
|
+
__exportStar(require("./CompressionConfiguration.js"), exports);
|
|
29
31
|
__exportStar(require("./Errors.js"), exports);
|
|
32
|
+
__exportStar(require("./EvictionPolicy.js"), exports);
|
|
30
33
|
__exportStar(require("./GlideClient.js"), exports);
|
|
31
34
|
__exportStar(require("./GlideClusterClient.js"), exports);
|
|
32
35
|
__exportStar(require("./Logger.js"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
3
3
|
*/
|
|
4
|
-
import { DecoderOption, GlideRecord, GlideReturnType, GlideString, GlideClient, GlideClusterClient, Field, FtAggregateOptions, FtCreateOptions, FtSearchOptions } from "..";
|
|
4
|
+
import { DecoderOption, GlideRecord, GlideReturnType, GlideString, GlideClient, GlideClusterClient, Field, FtAggregateOptions, FtCreateOptions, FtInfoOptions, FtSearchOptions } from "..";
|
|
5
5
|
/** Response type of {@link GlideFt.info | ft.info} command. */
|
|
6
6
|
export type FtInfoReturnType = Record<string, GlideString | number | GlideString[] | Record<string, GlideString | Record<string, GlideString | number>[]>>;
|
|
7
7
|
/**
|
|
@@ -44,6 +44,26 @@ export declare class GlideFt {
|
|
|
44
44
|
* dataType: "JSON",
|
|
45
45
|
* prefixes: ["json:"]
|
|
46
46
|
* });
|
|
47
|
+
*
|
|
48
|
+
* // Create a text search index with all options:
|
|
49
|
+
* // Note: noStopWords/stopWords are mutually exclusive;
|
|
50
|
+
* // withOffsets/noOffsets are mutually exclusive.
|
|
51
|
+
* await GlideFt.create(client, "text_idx", [
|
|
52
|
+
* { type: "TEXT", name: "title", sortable: true, nostem: true, weight: 2.0,
|
|
53
|
+
* withsuffixtrie: true },
|
|
54
|
+
* { type: "NUMERIC", name: "price", sortable: true },
|
|
55
|
+
* { type: "TAG", name: "category", sortable: true },
|
|
56
|
+
* ], {
|
|
57
|
+
* dataType: "HASH",
|
|
58
|
+
* prefixes: ["product:"],
|
|
59
|
+
* score: 1.0,
|
|
60
|
+
* language: "english",
|
|
61
|
+
* skipInitialScan: true,
|
|
62
|
+
* minStemSize: 4,
|
|
63
|
+
* withOffsets: true,
|
|
64
|
+
* stopWords: ["the", "a", "is"],
|
|
65
|
+
* punctuation: ".,;!?",
|
|
66
|
+
* });
|
|
47
67
|
* ```
|
|
48
68
|
*/
|
|
49
69
|
static create(client: GlideClient | GlideClusterClient, indexName: GlideString, schema: Field[], options?: FtCreateOptions): Promise<"OK">;
|
|
@@ -135,6 +155,10 @@ export declare class GlideFt {
|
|
|
135
155
|
* // }
|
|
136
156
|
* // ]
|
|
137
157
|
* // ]
|
|
158
|
+
*
|
|
159
|
+
* // Aggregate with all query flags:
|
|
160
|
+
* const result12 = await GlideFt.aggregate(client, "myIndex", "@score:[20 +inf]",
|
|
161
|
+
* { loadAll: true, verbatim: true, inorder: true, slop: 1, dialect: 2 });
|
|
138
162
|
* ```
|
|
139
163
|
*/
|
|
140
164
|
static aggregate(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: DecoderOption & FtAggregateOptions): Promise<FtAggregateReturnType>;
|
|
@@ -187,9 +211,19 @@ export declare class GlideFt {
|
|
|
187
211
|
* // },
|
|
188
212
|
* // ]
|
|
189
213
|
* // }
|
|
214
|
+
*
|
|
215
|
+
* // Get info with scope options:
|
|
216
|
+
* const localInfo = await GlideFt.info(client, "myIndex", { scope: "LOCAL" });
|
|
217
|
+
*
|
|
218
|
+
* // Get cluster-wide info (requires coordinator):
|
|
219
|
+
* const clusterInfo = await GlideFt.info(client, "myIndex", {
|
|
220
|
+
* scope: "PRIMARY",
|
|
221
|
+
* shardScope: "ALLSHARDS",
|
|
222
|
+
* consistency: "CONSISTENT",
|
|
223
|
+
* });
|
|
190
224
|
* ```
|
|
191
225
|
*/
|
|
192
|
-
static info(client: GlideClient | GlideClusterClient, indexName: GlideString, options?: DecoderOption): Promise<FtInfoReturnType>;
|
|
226
|
+
static info(client: GlideClient | GlideClusterClient, indexName: GlideString, options?: DecoderOption & FtInfoOptions): Promise<FtInfoReturnType>;
|
|
193
227
|
/**
|
|
194
228
|
* Parse a query and return information about how that query was parsed.
|
|
195
229
|
*
|
|
@@ -237,6 +271,7 @@ export declare class GlideFt {
|
|
|
237
271
|
* @returns A two-element array, where the first element is the number of documents in the result set, and the
|
|
238
272
|
* second element has the format: `GlideRecord<GlideRecord<GlideString>>`:
|
|
239
273
|
* a mapping between document names and a map of their attributes.
|
|
274
|
+
* When `nocontent` is set, the attribute maps will be empty.
|
|
240
275
|
*
|
|
241
276
|
* If `count` or `limit` with values `{offset: 0, count: 0}` is
|
|
242
277
|
* set, the command returns array with only one element: the number of documents.
|
|
@@ -278,6 +313,20 @@ export declare class GlideFt {
|
|
|
278
313
|
* // },
|
|
279
314
|
* // ],
|
|
280
315
|
* // ]
|
|
316
|
+
*
|
|
317
|
+
* // Text search with all options:
|
|
318
|
+
* // Note: withSortKeys requires sortby; shardScope/consistency are cluster-mode options.
|
|
319
|
+
* const textResult = await GlideFt.search(client, "myIndex", "hello world", {
|
|
320
|
+
* verbatim: true,
|
|
321
|
+
* inorder: true,
|
|
322
|
+
* slop: 1,
|
|
323
|
+
* sortby: "price",
|
|
324
|
+
* sortbyOrder: SortOrder.ASC,
|
|
325
|
+
* withsortkeys: true,
|
|
326
|
+
* shardScope: "ALLSHARDS",
|
|
327
|
+
* consistency: "CONSISTENT",
|
|
328
|
+
* dialect: 2,
|
|
329
|
+
* });
|
|
281
330
|
* ```
|
|
282
331
|
*/
|
|
283
332
|
static search(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: FtSearchOptions & DecoderOption): Promise<FtSearchReturnType>;
|
|
@@ -34,6 +34,26 @@ class GlideFt {
|
|
|
34
34
|
* dataType: "JSON",
|
|
35
35
|
* prefixes: ["json:"]
|
|
36
36
|
* });
|
|
37
|
+
*
|
|
38
|
+
* // Create a text search index with all options:
|
|
39
|
+
* // Note: noStopWords/stopWords are mutually exclusive;
|
|
40
|
+
* // withOffsets/noOffsets are mutually exclusive.
|
|
41
|
+
* await GlideFt.create(client, "text_idx", [
|
|
42
|
+
* { type: "TEXT", name: "title", sortable: true, nostem: true, weight: 2.0,
|
|
43
|
+
* withsuffixtrie: true },
|
|
44
|
+
* { type: "NUMERIC", name: "price", sortable: true },
|
|
45
|
+
* { type: "TAG", name: "category", sortable: true },
|
|
46
|
+
* ], {
|
|
47
|
+
* dataType: "HASH",
|
|
48
|
+
* prefixes: ["product:"],
|
|
49
|
+
* score: 1.0,
|
|
50
|
+
* language: "english",
|
|
51
|
+
* skipInitialScan: true,
|
|
52
|
+
* minStemSize: 4,
|
|
53
|
+
* withOffsets: true,
|
|
54
|
+
* stopWords: ["the", "a", "is"],
|
|
55
|
+
* punctuation: ".,;!?",
|
|
56
|
+
* });
|
|
37
57
|
* ```
|
|
38
58
|
*/
|
|
39
59
|
static async create(client, indexName, schema, options) {
|
|
@@ -45,6 +65,39 @@ class GlideFt {
|
|
|
45
65
|
if ("prefixes" in options && options.prefixes) {
|
|
46
66
|
args.push("PREFIX", options.prefixes.length.toString(), ...options.prefixes);
|
|
47
67
|
}
|
|
68
|
+
if (options.score !== undefined) {
|
|
69
|
+
args.push("SCORE", options.score.toString());
|
|
70
|
+
}
|
|
71
|
+
if (options.language) {
|
|
72
|
+
args.push("LANGUAGE", options.language);
|
|
73
|
+
}
|
|
74
|
+
if (options.skipInitialScan) {
|
|
75
|
+
args.push("SKIPINITIALSCAN");
|
|
76
|
+
}
|
|
77
|
+
if (options.minStemSize !== undefined) {
|
|
78
|
+
args.push("MINSTEMSIZE", options.minStemSize.toString());
|
|
79
|
+
}
|
|
80
|
+
if (options.withOffsets && options.noOffsets) {
|
|
81
|
+
throw new Error("withOffsets and noOffsets are mutually exclusive.");
|
|
82
|
+
}
|
|
83
|
+
if (options.noStopWords && options.stopWords) {
|
|
84
|
+
throw new Error("noStopWords and stopWords are mutually exclusive.");
|
|
85
|
+
}
|
|
86
|
+
if (options.withOffsets) {
|
|
87
|
+
args.push("WITHOFFSETS");
|
|
88
|
+
}
|
|
89
|
+
else if (options.noOffsets) {
|
|
90
|
+
args.push("NOOFFSETS");
|
|
91
|
+
}
|
|
92
|
+
if (options.noStopWords) {
|
|
93
|
+
args.push("NOSTOPWORDS");
|
|
94
|
+
}
|
|
95
|
+
else if (options.stopWords) {
|
|
96
|
+
args.push("STOPWORDS", options.stopWords.length.toString(), ...options.stopWords);
|
|
97
|
+
}
|
|
98
|
+
if (options.punctuation) {
|
|
99
|
+
args.push("PUNCTUATION", options.punctuation);
|
|
100
|
+
}
|
|
48
101
|
}
|
|
49
102
|
args.push("SCHEMA");
|
|
50
103
|
schema.forEach((f) => {
|
|
@@ -54,6 +107,24 @@ class GlideFt {
|
|
|
54
107
|
}
|
|
55
108
|
args.push(f.type);
|
|
56
109
|
switch (f.type) {
|
|
110
|
+
case "TEXT": {
|
|
111
|
+
if (f.nostem) {
|
|
112
|
+
args.push("NOSTEM");
|
|
113
|
+
}
|
|
114
|
+
if (f.weight !== undefined) {
|
|
115
|
+
args.push("WEIGHT", f.weight.toString());
|
|
116
|
+
}
|
|
117
|
+
if (f.withsuffixtrie) {
|
|
118
|
+
args.push("WITHSUFFIXTRIE");
|
|
119
|
+
}
|
|
120
|
+
else if (f.nosuffixtrie) {
|
|
121
|
+
args.push("NOSUFFIXTRIE");
|
|
122
|
+
}
|
|
123
|
+
if (f.sortable) {
|
|
124
|
+
args.push("SORTABLE");
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
57
128
|
case "TAG": {
|
|
58
129
|
if (f.separator) {
|
|
59
130
|
args.push("SEPARATOR", f.separator);
|
|
@@ -61,6 +132,15 @@ class GlideFt {
|
|
|
61
132
|
if (f.caseSensitive) {
|
|
62
133
|
args.push("CASESENSITIVE");
|
|
63
134
|
}
|
|
135
|
+
if (f.sortable) {
|
|
136
|
+
args.push("SORTABLE");
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "NUMERIC": {
|
|
141
|
+
if (f.sortable) {
|
|
142
|
+
args.push("SORTABLE");
|
|
143
|
+
}
|
|
64
144
|
break;
|
|
65
145
|
}
|
|
66
146
|
case "VECTOR": {
|
|
@@ -84,16 +164,17 @@ class GlideFt {
|
|
|
84
164
|
attributes.push("INITIAL_CAP", f.attributes.initialCap.toString());
|
|
85
165
|
}
|
|
86
166
|
// VectorFieldAttributesHnsw attributes
|
|
87
|
-
if ("
|
|
88
|
-
|
|
167
|
+
if ("numberOfEdges" in f.attributes &&
|
|
168
|
+
f.attributes.numberOfEdges) {
|
|
169
|
+
attributes.push("M", f.attributes.numberOfEdges.toString());
|
|
89
170
|
}
|
|
90
|
-
if ("
|
|
91
|
-
f.attributes.
|
|
92
|
-
attributes.push("EF_CONSTRUCTION", f.attributes.
|
|
171
|
+
if ("vectorsExaminedOnConstruction" in f.attributes &&
|
|
172
|
+
f.attributes.vectorsExaminedOnConstruction) {
|
|
173
|
+
attributes.push("EF_CONSTRUCTION", f.attributes.vectorsExaminedOnConstruction.toString());
|
|
93
174
|
}
|
|
94
|
-
if ("
|
|
95
|
-
f.attributes.
|
|
96
|
-
attributes.push("EF_RUNTIME", f.attributes.
|
|
175
|
+
if ("vectorsExaminedOnRuntime" in f.attributes &&
|
|
176
|
+
f.attributes.vectorsExaminedOnRuntime) {
|
|
177
|
+
attributes.push("EF_RUNTIME", f.attributes.vectorsExaminedOnRuntime.toString());
|
|
97
178
|
}
|
|
98
179
|
args.push(attributes.length.toString(), ...attributes);
|
|
99
180
|
}
|
|
@@ -202,6 +283,10 @@ class GlideFt {
|
|
|
202
283
|
* // }
|
|
203
284
|
* // ]
|
|
204
285
|
* // ]
|
|
286
|
+
*
|
|
287
|
+
* // Aggregate with all query flags:
|
|
288
|
+
* const result12 = await GlideFt.aggregate(client, "myIndex", "@score:[20 +inf]",
|
|
289
|
+
* { loadAll: true, verbatim: true, inorder: true, slop: 1, dialect: 2 });
|
|
205
290
|
* ```
|
|
206
291
|
*/
|
|
207
292
|
static async aggregate(client, indexName, query, options) {
|
|
@@ -262,10 +347,29 @@ class GlideFt {
|
|
|
262
347
|
* // },
|
|
263
348
|
* // ]
|
|
264
349
|
* // }
|
|
350
|
+
*
|
|
351
|
+
* // Get info with scope options:
|
|
352
|
+
* const localInfo = await GlideFt.info(client, "myIndex", { scope: "LOCAL" });
|
|
353
|
+
*
|
|
354
|
+
* // Get cluster-wide info (requires coordinator):
|
|
355
|
+
* const clusterInfo = await GlideFt.info(client, "myIndex", {
|
|
356
|
+
* scope: "PRIMARY",
|
|
357
|
+
* shardScope: "ALLSHARDS",
|
|
358
|
+
* consistency: "CONSISTENT",
|
|
359
|
+
* });
|
|
265
360
|
* ```
|
|
266
361
|
*/
|
|
267
362
|
static async info(client, indexName, options) {
|
|
268
363
|
const args = ["FT.INFO", indexName];
|
|
364
|
+
if (options?.scope) {
|
|
365
|
+
args.push(options.scope);
|
|
366
|
+
}
|
|
367
|
+
if (options?.shardScope) {
|
|
368
|
+
args.push(options.shardScope);
|
|
369
|
+
}
|
|
370
|
+
if (options?.consistency) {
|
|
371
|
+
args.push(options.consistency);
|
|
372
|
+
}
|
|
269
373
|
return _handleCustomCommand(client, args, options).then(__1.convertGlideRecordToRecord);
|
|
270
374
|
}
|
|
271
375
|
/**
|
|
@@ -321,6 +425,7 @@ class GlideFt {
|
|
|
321
425
|
* @returns A two-element array, where the first element is the number of documents in the result set, and the
|
|
322
426
|
* second element has the format: `GlideRecord<GlideRecord<GlideString>>`:
|
|
323
427
|
* a mapping between document names and a map of their attributes.
|
|
428
|
+
* When `nocontent` is set, the attribute maps will be empty.
|
|
324
429
|
*
|
|
325
430
|
* If `count` or `limit` with values `{offset: 0, count: 0}` is
|
|
326
431
|
* set, the command returns array with only one element: the number of documents.
|
|
@@ -362,6 +467,20 @@ class GlideFt {
|
|
|
362
467
|
* // },
|
|
363
468
|
* // ],
|
|
364
469
|
* // ]
|
|
470
|
+
*
|
|
471
|
+
* // Text search with all options:
|
|
472
|
+
* // Note: withSortKeys requires sortby; shardScope/consistency are cluster-mode options.
|
|
473
|
+
* const textResult = await GlideFt.search(client, "myIndex", "hello world", {
|
|
474
|
+
* verbatim: true,
|
|
475
|
+
* inorder: true,
|
|
476
|
+
* slop: 1,
|
|
477
|
+
* sortby: "price",
|
|
478
|
+
* sortbyOrder: SortOrder.ASC,
|
|
479
|
+
* withsortkeys: true,
|
|
480
|
+
* shardScope: "ALLSHARDS",
|
|
481
|
+
* consistency: "CONSISTENT",
|
|
482
|
+
* dialect: 2,
|
|
483
|
+
* });
|
|
365
484
|
* ```
|
|
366
485
|
*/
|
|
367
486
|
static async search(client, indexName, query, options) {
|
|
@@ -541,6 +660,12 @@ function _addFtAggregateOptions(options) {
|
|
|
541
660
|
if (!options)
|
|
542
661
|
return [];
|
|
543
662
|
const args = [];
|
|
663
|
+
if (options.verbatim)
|
|
664
|
+
args.push("VERBATIM");
|
|
665
|
+
if (options.inorder)
|
|
666
|
+
args.push("INORDER");
|
|
667
|
+
if (options.slop !== undefined)
|
|
668
|
+
args.push("SLOP", options.slop.toString());
|
|
544
669
|
if (options.loadAll)
|
|
545
670
|
args.push("LOAD", "*");
|
|
546
671
|
else if (options.loadFields)
|
|
@@ -582,6 +707,8 @@ function _addFtAggregateOptions(options) {
|
|
|
582
707
|
}
|
|
583
708
|
}
|
|
584
709
|
}
|
|
710
|
+
if (options.dialect !== undefined)
|
|
711
|
+
args.push("DIALECT", options.dialect.toString());
|
|
585
712
|
return args;
|
|
586
713
|
}
|
|
587
714
|
/**
|
|
@@ -590,7 +717,37 @@ function _addFtAggregateOptions(options) {
|
|
|
590
717
|
function _addFtSearchOptions(options) {
|
|
591
718
|
if (!options)
|
|
592
719
|
return [];
|
|
720
|
+
if (!options.sortby && options.sortbyOrder) {
|
|
721
|
+
throw new Error("sortbyOrder requires sortby to be set.");
|
|
722
|
+
}
|
|
723
|
+
if (!options.sortby && options.withsortkeys) {
|
|
724
|
+
throw new Error("withsortkeys requires sortby to be set.");
|
|
725
|
+
}
|
|
593
726
|
const args = [];
|
|
727
|
+
// SHARD SCOPE
|
|
728
|
+
if (options.shardScope) {
|
|
729
|
+
args.push(options.shardScope);
|
|
730
|
+
}
|
|
731
|
+
// CONSISTENCY
|
|
732
|
+
if (options.consistency) {
|
|
733
|
+
args.push(options.consistency);
|
|
734
|
+
}
|
|
735
|
+
// NOCONTENT
|
|
736
|
+
if (options.nocontent) {
|
|
737
|
+
args.push("NOCONTENT");
|
|
738
|
+
}
|
|
739
|
+
// VERBATIM
|
|
740
|
+
if (options.verbatim) {
|
|
741
|
+
args.push("VERBATIM");
|
|
742
|
+
}
|
|
743
|
+
// INORDER
|
|
744
|
+
if (options.inorder) {
|
|
745
|
+
args.push("INORDER");
|
|
746
|
+
}
|
|
747
|
+
// SLOP
|
|
748
|
+
if (options.slop !== undefined) {
|
|
749
|
+
args.push("SLOP", options.slop.toString());
|
|
750
|
+
}
|
|
594
751
|
// RETURN
|
|
595
752
|
if (options.returnFields) {
|
|
596
753
|
const returnFields = [];
|
|
@@ -599,6 +756,17 @@ function _addFtSearchOptions(options) {
|
|
|
599
756
|
: returnFields.push(returnField.fieldIdentifier));
|
|
600
757
|
args.push("RETURN", returnFields.length.toString(), ...returnFields);
|
|
601
758
|
}
|
|
759
|
+
// SORTBY
|
|
760
|
+
if (options.sortby) {
|
|
761
|
+
args.push("SORTBY", options.sortby);
|
|
762
|
+
if (options.sortbyOrder) {
|
|
763
|
+
args.push(options.sortbyOrder);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
// WITHSORTKEYS
|
|
767
|
+
if (options.withsortkeys) {
|
|
768
|
+
args.push("WITHSORTKEYS");
|
|
769
|
+
}
|
|
602
770
|
// TIMEOUT
|
|
603
771
|
if (options.timeout) {
|
|
604
772
|
args.push("TIMEOUT", options.timeout.toString());
|
|
@@ -615,6 +783,10 @@ function _addFtSearchOptions(options) {
|
|
|
615
783
|
if (options.count) {
|
|
616
784
|
args.push("COUNT");
|
|
617
785
|
}
|
|
786
|
+
// DIALECT
|
|
787
|
+
if (options.dialect !== undefined) {
|
|
788
|
+
args.push("DIALECT", options.dialect.toString());
|
|
789
|
+
}
|
|
618
790
|
return args;
|
|
619
791
|
}
|
|
620
792
|
/**
|
|
@@ -7,6 +7,8 @@ interface BaseField {
|
|
|
7
7
|
name: GlideString;
|
|
8
8
|
/** An alias for field. */
|
|
9
9
|
alias?: GlideString;
|
|
10
|
+
/** If set, the field value can be used for sorting. Applies to TEXT, TAG, and NUMERIC fields. */
|
|
11
|
+
sortable?: boolean;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* Field contains any blob of data.
|
|
@@ -14,6 +16,20 @@ interface BaseField {
|
|
|
14
16
|
export type TextField = BaseField & {
|
|
15
17
|
/** Field identifier */
|
|
16
18
|
type: "TEXT";
|
|
19
|
+
/** If set, disables stemming when indexing the field. */
|
|
20
|
+
nostem?: boolean;
|
|
21
|
+
/** Declares the importance of this field when calculating result accuracy. Default is 1. */
|
|
22
|
+
weight?: number;
|
|
23
|
+
/**
|
|
24
|
+
* If set, keeps a suffix trie for the field to optimize contains and suffix queries.
|
|
25
|
+
* Mutually exclusive with `nosuffixtrie`.
|
|
26
|
+
*/
|
|
27
|
+
withsuffixtrie?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* If set, disables the suffix trie for the field.
|
|
30
|
+
* Mutually exclusive with `withsuffixtrie`.
|
|
31
|
+
*/
|
|
32
|
+
nosuffixtrie?: boolean;
|
|
17
33
|
};
|
|
18
34
|
/**
|
|
19
35
|
* Tag fields are similar to full-text fields, but they interpret the text as a simple list of
|
|
@@ -53,13 +69,15 @@ interface VectorFieldAttributes {
|
|
|
53
69
|
/** Number of dimensions in the vector. Equivalent to `DIM` in the module API. */
|
|
54
70
|
dimensions: number;
|
|
55
71
|
/**
|
|
56
|
-
* The distance metric used in vector type field. Can be one of `[L2 | IP | COSINE]`.
|
|
72
|
+
* The distance metric used in vector type field. Can be one of `[L2 | IP | COSINE]`.
|
|
73
|
+
* Equivalent to `DISTANCE_METRIC` in the module API.
|
|
57
74
|
*/
|
|
58
75
|
distanceMetric: "L2" | "IP" | "COSINE";
|
|
59
76
|
/** Vector type. The only supported type is FLOAT32. */
|
|
60
77
|
type?: "FLOAT32";
|
|
61
78
|
/**
|
|
62
|
-
* Initial vector capacity in the index affecting memory allocation size of the index.
|
|
79
|
+
* Initial vector capacity in the index affecting memory allocation size of the index.
|
|
80
|
+
* Defaults to `1024`. Equivalent to `INITIAL_CAP` in the module API.
|
|
63
81
|
*/
|
|
64
82
|
initialCap?: number;
|
|
65
83
|
}
|
|
@@ -81,18 +99,18 @@ export type VectorFieldAttributesFlat = VectorFieldAttributes & {
|
|
|
81
99
|
export type VectorFieldAttributesHnsw = VectorFieldAttributes & {
|
|
82
100
|
algorithm: "HNSW";
|
|
83
101
|
/**
|
|
84
|
-
* Number of maximum allowed outgoing edges for each node in the graph in each layer.
|
|
85
|
-
* Equivalent to `M` in the module API.
|
|
102
|
+
* Number of maximum allowed outgoing edges for each node in the graph in each layer.
|
|
103
|
+
* Default is `16`, maximum is `512`. Equivalent to `M` in the module API.
|
|
86
104
|
*/
|
|
87
105
|
numberOfEdges?: number;
|
|
88
106
|
/**
|
|
89
|
-
* Controls the number of vectors examined during index construction.
|
|
90
|
-
* Equivalent to `EF_CONSTRUCTION` in the module API.
|
|
107
|
+
* Controls the number of vectors examined during index construction.
|
|
108
|
+
* Default value is `200`, Maximum value is `4096`. Equivalent to `EF_CONSTRUCTION` in the module API.
|
|
91
109
|
*/
|
|
92
110
|
vectorsExaminedOnConstruction?: number;
|
|
93
111
|
/**
|
|
94
|
-
* Controls the number of vectors examined during query operations.
|
|
95
|
-
* Equivalent to `EF_RUNTIME` in the module API.
|
|
112
|
+
* Controls the number of vectors examined during query operations.
|
|
113
|
+
* Default value is `10`, Maximum value is `4096`. Equivalent to `EF_RUNTIME` in the module API.
|
|
96
114
|
*/
|
|
97
115
|
vectorsExaminedOnRuntime?: number;
|
|
98
116
|
};
|
|
@@ -106,6 +124,36 @@ export interface FtCreateOptions {
|
|
|
106
124
|
dataType: "JSON" | "HASH";
|
|
107
125
|
/** The prefix of the key to be indexed. */
|
|
108
126
|
prefixes?: GlideString[];
|
|
127
|
+
/** Default score for documents in the index. Default is 1.0. */
|
|
128
|
+
score?: number;
|
|
129
|
+
/** Default language for documents in the index. */
|
|
130
|
+
language?: string;
|
|
131
|
+
/** If set, does not scan and index existing documents on index creation. */
|
|
132
|
+
skipInitialScan?: boolean;
|
|
133
|
+
/** Minimum word length to stem. Words shorter than this are not stemmed. */
|
|
134
|
+
minStemSize?: number;
|
|
135
|
+
/**
|
|
136
|
+
* If set, stores term offsets for document fields.
|
|
137
|
+
* Mutually exclusive with `noOffsets`.
|
|
138
|
+
*/
|
|
139
|
+
withOffsets?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* If set, does not store term offsets.
|
|
142
|
+
* Mutually exclusive with `withOffsets`.
|
|
143
|
+
*/
|
|
144
|
+
noOffsets?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* If set, disables stop-word filtering.
|
|
147
|
+
* Mutually exclusive with `stopWords`.
|
|
148
|
+
*/
|
|
149
|
+
noStopWords?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Custom list of stop words.
|
|
152
|
+
* Mutually exclusive with `noStopWords`.
|
|
153
|
+
*/
|
|
154
|
+
stopWords?: GlideString[];
|
|
155
|
+
/** Custom punctuation characters to use during tokenization. */
|
|
156
|
+
punctuation?: GlideString;
|
|
109
157
|
}
|
|
110
158
|
/** Additional parameters for {@link GlideFt.aggregate | FT.AGGREGATE} command. */
|
|
111
159
|
export type FtAggregateOptions = {
|
|
@@ -123,6 +171,14 @@ export type FtAggregateOptions = {
|
|
|
123
171
|
* the parameter name.
|
|
124
172
|
*/
|
|
125
173
|
params?: GlideRecord<GlideString>;
|
|
174
|
+
/** If set, stemming is not applied to term searches. */
|
|
175
|
+
verbatim?: boolean;
|
|
176
|
+
/** If set, proximity matching of terms must be in order. */
|
|
177
|
+
inorder?: boolean;
|
|
178
|
+
/** Specifies a slop value for proximity matching of terms. */
|
|
179
|
+
slop?: number;
|
|
180
|
+
/** The query dialect version to use. */
|
|
181
|
+
dialect?: number;
|
|
126
182
|
} & ({
|
|
127
183
|
/** List of fields to load from the index. */
|
|
128
184
|
loadFields?: GlideString[];
|
|
@@ -218,6 +274,39 @@ export type FtSearchOptions = {
|
|
|
218
274
|
* the parameter name.
|
|
219
275
|
*/
|
|
220
276
|
params?: GlideRecord<GlideString>;
|
|
277
|
+
/** If true, returns only document IDs without field content.
|
|
278
|
+
* The document entries in the result will have empty value arrays. */
|
|
279
|
+
nocontent?: boolean;
|
|
280
|
+
/** Query dialect version. Only dialect 2 is currently supported in valkey-search. */
|
|
281
|
+
dialect?: number;
|
|
282
|
+
/** If set, stemming is not applied to text terms in the query. */
|
|
283
|
+
verbatim?: boolean;
|
|
284
|
+
/** If set, proximity matching of text terms must be in order. */
|
|
285
|
+
inorder?: boolean;
|
|
286
|
+
/** Specifies a slop value for proximity matching of text terms. */
|
|
287
|
+
slop?: number;
|
|
288
|
+
/** Field name to sort results by. Sorting is applied before the LIMIT clause. */
|
|
289
|
+
sortby?: GlideString;
|
|
290
|
+
/** Sort direction for `sortby`. Only used when `sortby` is set. */
|
|
291
|
+
sortbyOrder?: SortOrder | "ASC" | "DESC";
|
|
292
|
+
/** If set and `sortby` is specified, augments the output with the sort key value.
|
|
293
|
+
* When enabled, each document value in the result map becomes a two-element array
|
|
294
|
+
* `[sortKey, fieldMap]` instead of just `fieldMap`. The sort key is the value of the
|
|
295
|
+
* field used for sorting, or `null` if the field is missing from the document.
|
|
296
|
+
*/
|
|
297
|
+
withsortkeys?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Controls shard participation in cluster mode.
|
|
300
|
+
* `ALLSHARDS` terminates with timeout error if not all shards respond (default).
|
|
301
|
+
* `SOMESHARDS` generates a best-effort reply if not all shards respond within the timeout.
|
|
302
|
+
*/
|
|
303
|
+
shardScope?: "ALLSHARDS" | "SOMESHARDS";
|
|
304
|
+
/**
|
|
305
|
+
* Controls consistency requirements in cluster mode.
|
|
306
|
+
* `CONSISTENT` terminates with an error if the cluster is in an inconsistent state (default).
|
|
307
|
+
* `INCONSISTENT` generates a best-effort reply if the cluster remains inconsistent within the timeout.
|
|
308
|
+
*/
|
|
309
|
+
consistency?: "CONSISTENT" | "INCONSISTENT";
|
|
221
310
|
} & ({
|
|
222
311
|
/**
|
|
223
312
|
* Configure query pagination. By default only first 10 documents are returned.
|
|
@@ -240,4 +329,13 @@ export type FtSearchOptions = {
|
|
|
240
329
|
/** `limit` and `count` are mutually exclusive. */
|
|
241
330
|
limit?: never;
|
|
242
331
|
});
|
|
332
|
+
/** Additional parameters for {@link GlideFt.info | FT.INFO} command. */
|
|
333
|
+
export interface FtInfoOptions {
|
|
334
|
+
/** Controls which nodes provide index information in cluster mode. */
|
|
335
|
+
scope?: "LOCAL" | "PRIMARY" | "CLUSTER";
|
|
336
|
+
/** Controls shard participation in cluster mode. */
|
|
337
|
+
shardScope?: "ALLSHARDS" | "SOMESHARDS";
|
|
338
|
+
/** Controls consistency requirements in cluster mode. */
|
|
339
|
+
consistency?: "CONSISTENT" | "INCONSISTENT";
|
|
340
|
+
}
|
|
243
341
|
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "build-ts/index.js",
|
|
5
5
|
"module": "build-ts/index.js",
|
|
6
6
|
"types": "build-ts/index.d.ts",
|
|
7
|
-
"version": "2.
|
|
7
|
+
"version": "2.4.0-rc2",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": {
|
|
@@ -135,11 +135,11 @@
|
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
"optionalDependencies": {
|
|
138
|
-
"@valkey/valkey-glide-darwin-x64": "2.
|
|
139
|
-
"@valkey/valkey-glide-darwin-arm64": "2.
|
|
140
|
-
"@valkey/valkey-glide-linux-x64-gnu": "2.
|
|
141
|
-
"@valkey/valkey-glide-linux-arm64-gnu": "2.
|
|
142
|
-
"@valkey/valkey-glide-linux-x64-musl": "2.
|
|
143
|
-
"@valkey/valkey-glide-linux-arm64-musl": "2.
|
|
138
|
+
"@valkey/valkey-glide-darwin-x64": "2.4.0-rc2",
|
|
139
|
+
"@valkey/valkey-glide-darwin-arm64": "2.4.0-rc2",
|
|
140
|
+
"@valkey/valkey-glide-linux-x64-gnu": "2.4.0-rc2",
|
|
141
|
+
"@valkey/valkey-glide-linux-arm64-gnu": "2.4.0-rc2",
|
|
142
|
+
"@valkey/valkey-glide-linux-x64-musl": "2.4.0-rc2",
|
|
143
|
+
"@valkey/valkey-glide-linux-arm64-musl": "2.4.0-rc2"
|
|
144
144
|
}
|
|
145
145
|
}
|