@valkey/valkey-glide 1.2.0-rc9 → 1.2.0

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.
@@ -0,0 +1,412 @@
1
+ /**
2
+ * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
+ */
4
+ import { DecoderOption, GlideRecord, GlideReturnType, GlideString } from "../BaseClient";
5
+ import { GlideClient } from "../GlideClient";
6
+ import { GlideClusterClient } from "../GlideClusterClient";
7
+ import { Field, FtAggregateOptions, FtCreateOptions, FtSearchOptions } from "./GlideFtOptions";
8
+ /** Response type of {@link GlideFt.info | ft.info} command. */
9
+ export type FtInfoReturnType = Record<string, GlideString | number | GlideString[] | Record<string, GlideString | Record<string, GlideString | number>[]>>;
10
+ /**
11
+ * Response type for the {@link GlideFt.search | ft.search} command.
12
+ */
13
+ export type FtSearchReturnType = [
14
+ number,
15
+ GlideRecord<GlideRecord<GlideString>>
16
+ ];
17
+ /**
18
+ * Response type for the {@link GlideFt.aggregate | ft.aggregate} command.
19
+ */
20
+ export type FtAggregateReturnType = GlideRecord<GlideReturnType>[];
21
+ /** Module for Vector Search commands. */
22
+ export declare class GlideFt {
23
+ /**
24
+ * Creates an index and initiates a backfill of that index.
25
+ *
26
+ * @param client - The client to execute the command.
27
+ * @param indexName - The index name for the index to be created.
28
+ * @param schema - The fields of the index schema, specifying the fields and their types.
29
+ * @param options - (Optional) Options for the `FT.CREATE` command. See {@link FtCreateOptions}.
30
+ * @returns If the index is successfully created, returns "OK".
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Example usage of FT.CREATE to create a 6-dimensional JSON index using the HNSW algorithm
35
+ * await GlideFt.create(client, "json_idx1", [{
36
+ * type: "VECTOR",
37
+ * name: "$.vec",
38
+ * alias: "VEC",
39
+ * attributes: {
40
+ * algorithm: "HNSW",
41
+ * type: "FLOAT32",
42
+ * dimension: 6,
43
+ * distanceMetric: "L2",
44
+ * numberOfEdges: 32,
45
+ * },
46
+ * }], {
47
+ * dataType: "JSON",
48
+ * prefixes: ["json:"]
49
+ * });
50
+ * ```
51
+ */
52
+ static create(client: GlideClient | GlideClusterClient, indexName: GlideString, schema: Field[], options?: FtCreateOptions): Promise<"OK">;
53
+ /**
54
+ * Deletes an index and associated content. Indexed document keys are unaffected.
55
+ *
56
+ * @param client - The client to execute the command.
57
+ * @param indexName - The index name.
58
+ * @returns "OK"
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Example usage of FT.DROPINDEX to drop an index
63
+ * await GlideFt.dropindex(client, "json_idx1"); // "OK"
64
+ * ```
65
+ */
66
+ static dropindex(client: GlideClient | GlideClusterClient, indexName: GlideString): Promise<"OK">;
67
+ /**
68
+ * Lists all indexes.
69
+ *
70
+ * @param client - The client to execute the command.
71
+ * @param options - (Optional) See {@link DecoderOption}.
72
+ * @returns An array of index names.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * console.log(await GlideFt.list(client)); // Output: ["index1", "index2"]
77
+ * ```
78
+ */
79
+ static list(client: GlideClient | GlideClusterClient, options?: DecoderOption): Promise<GlideString[]>;
80
+ /**
81
+ * Runs a search query on an index, and perform aggregate transformations on the results.
82
+ *
83
+ * @param client - The client to execute the command.
84
+ * @param indexName - The index name.
85
+ * @param query - The text query to search.
86
+ * @param options - Additional parameters for the command - see {@link FtAggregateOptions} and {@link DecoderOption}.
87
+ * @returns Results of the last stage of the pipeline.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const options: FtAggregateOptions = {
92
+ * loadFields: ["__key"],
93
+ * clauses: [
94
+ * {
95
+ * type: "GROUPBY",
96
+ * properties: ["@condition"],
97
+ * reducers: [
98
+ * {
99
+ * function: "TOLIST",
100
+ * args: ["__key"],
101
+ * name: "bicycles",
102
+ * },
103
+ * ],
104
+ * },
105
+ * ],
106
+ * };
107
+ * const result = await GlideFt.aggregate(client, "myIndex", "*", options);
108
+ * console.log(result); // Output:
109
+ * // [
110
+ * // [
111
+ * // {
112
+ * // key: "condition",
113
+ * // value: "refurbished"
114
+ * // },
115
+ * // {
116
+ * // key: "bicycles",
117
+ * // value: [ "bicycle:9" ]
118
+ * // }
119
+ * // ],
120
+ * // [
121
+ * // {
122
+ * // key: "condition",
123
+ * // value: "used"
124
+ * // },
125
+ * // {
126
+ * // key: "bicycles",
127
+ * // value: [ "bicycle:1", "bicycle:2", "bicycle:3" ]
128
+ * // }
129
+ * // ],
130
+ * // [
131
+ * // {
132
+ * // key: "condition",
133
+ * // value: "new"
134
+ * // },
135
+ * // {
136
+ * // key: "bicycles",
137
+ * // value: [ "bicycle:0", "bicycle:5" ]
138
+ * // }
139
+ * // ]
140
+ * // ]
141
+ * ```
142
+ */
143
+ static aggregate(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: DecoderOption & FtAggregateOptions): Promise<FtAggregateReturnType>;
144
+ /**
145
+ * Returns information about a given index.
146
+ *
147
+ * @param client - The client to execute the command.
148
+ * @param indexName - The index name.
149
+ * @param options - (Optional) See {@link DecoderOption}.
150
+ * @returns Nested maps with info about the index. See example for more details.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const info = await GlideFt.info(client, "myIndex");
155
+ * console.log(info); // Output:
156
+ * // {
157
+ * // index_name: 'myIndex',
158
+ * // index_status: 'AVAILABLE',
159
+ * // key_type: 'JSON',
160
+ * // creation_timestamp: 1728348101728771,
161
+ * // key_prefixes: [ 'json:' ],
162
+ * // num_indexed_vectors: 0,
163
+ * // space_usage: 653471,
164
+ * // num_docs: 0,
165
+ * // vector_space_usage: 653471,
166
+ * // index_degradation_percentage: 0,
167
+ * // fulltext_space_usage: 0,
168
+ * // current_lag: 0,
169
+ * // fields: [
170
+ * // {
171
+ * // identifier: '$.vec',
172
+ * // type: 'VECTOR',
173
+ * // field_name: 'VEC',
174
+ * // option: '',
175
+ * // vector_params: {
176
+ * // data_type: 'FLOAT32',
177
+ * // initial_capacity: 1000,
178
+ * // current_capacity: 1000,
179
+ * // distance_metric: 'L2',
180
+ * // dimension: 6,
181
+ * // block_size: 1024,
182
+ * // algorithm: 'FLAT'
183
+ * // }
184
+ * // },
185
+ * // {
186
+ * // identifier: 'name',
187
+ * // type: 'TEXT',
188
+ * // field_name: 'name',
189
+ * // option: ''
190
+ * // },
191
+ * // ]
192
+ * // }
193
+ * ```
194
+ */
195
+ static info(client: GlideClient | GlideClusterClient, indexName: GlideString, options?: DecoderOption): Promise<FtInfoReturnType>;
196
+ /**
197
+ * Parse a query and return information about how that query was parsed.
198
+ *
199
+ * @param client - The client to execute the command.
200
+ * @param indexName - The index name.
201
+ * @param query - The text query to search. It is the same as the query passed as
202
+ * an argument to {@link search | FT.SEARCH} or {@link aggregate | FT.AGGREGATE}.
203
+ * @param options - (Optional) See {@link DecoderOption}.
204
+ * @returns A query execution plan.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const result = GlideFt.explain(client, "myIndex", "@price:[0 10]");
209
+ * console.log(result); // Output: "Field {\n\tprice\n\t0\n\t10\n}"
210
+ * ```
211
+ */
212
+ static explain(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: DecoderOption): Promise<GlideString>;
213
+ /**
214
+ * Parse a query and return information about how that query was parsed.
215
+ * Same as {@link explain | FT.EXPLAIN}, except that the results are
216
+ * displayed in a different format.
217
+ *
218
+ * @param client - The client to execute the command.
219
+ * @param indexName - The index name.
220
+ * @param query - The text query to search. It is the same as the query passed as
221
+ * an argument to {@link search | FT.SEARCH} or {@link aggregate | FT.AGGREGATE}.
222
+ * @param options - (Optional) See {@link DecoderOption}.
223
+ * @returns A query execution plan.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const result = GlideFt.explaincli(client, "myIndex", "@price:[0 10]");
228
+ * console.log(result); // Output: ["Field {", "price", "0", "10", "}"]
229
+ * ```
230
+ */
231
+ static explaincli(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: DecoderOption): Promise<GlideString[]>;
232
+ /**
233
+ * Uses the provided query expression to locate keys within an index. Once located, the count
234
+ * and/or content of indexed fields within those keys can be returned.
235
+ *
236
+ * @param client - The client to execute the command.
237
+ * @param indexName - The index name to search into.
238
+ * @param query - The text query to search.
239
+ * @param options - (Optional) See {@link FtSearchOptions} and {@link DecoderOption}.
240
+ * @returns A two-element array, where the first element is the number of documents in the result set, and the
241
+ * second element has the format: `GlideRecord<GlideRecord<GlideString>>`:
242
+ * a mapping between document names and a map of their attributes.
243
+ *
244
+ * If `count` or `limit` with values `{offset: 0, count: 0}` is
245
+ * set, the command returns array with only one element: the number of documents.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * //
250
+ * const vector = Buffer.alloc(24);
251
+ * const result = await GlideFt.search(client, "json_idx1", "*=>[KNN 2 @VEC $query_vec]", {params: [{key: "query_vec", value: vector}]});
252
+ * console.log(result); // Output:
253
+ * // [
254
+ * // 2,
255
+ * // [
256
+ * // {
257
+ * // key: "json:2",
258
+ * // value: [
259
+ * // {
260
+ * // key: "$",
261
+ * // value: '{"vec":[1.1,1.2,1.3,1.4,1.5,1.6]}',
262
+ * // },
263
+ * // {
264
+ * // key: "__VEC_score",
265
+ * // value: "11.1100006104",
266
+ * // },
267
+ * // ],
268
+ * // },
269
+ * // {
270
+ * // key: "json:0",
271
+ * // value: [
272
+ * // {
273
+ * // key: "$",
274
+ * // value: '{"vec":[1,2,3,4,5,6]}',
275
+ * // },
276
+ * // {
277
+ * // key: "__VEC_score",
278
+ * // value: "91",
279
+ * // },
280
+ * // ],
281
+ * // },
282
+ * // ],
283
+ * // ]
284
+ * ```
285
+ */
286
+ static search(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: FtSearchOptions & DecoderOption): Promise<FtSearchReturnType>;
287
+ /**
288
+ * Runs a search query and collects performance profiling information.
289
+ *
290
+ * @param client - The client to execute the command.
291
+ * @param indexName - The index name.
292
+ * @param query - The text query to search.
293
+ * @param options - (Optional) See {@link FtSearchOptions} and {@link DecoderOption}. Additionally:
294
+ * - `limited` (Optional) - Either provide a full verbose output or some brief version.
295
+ *
296
+ * @returns A two-element array. The first element contains results of the search query being profiled, the
297
+ * second element stores profiling information.
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * // Example of running profile on a search query
302
+ * const vector = Buffer.alloc(24);
303
+ * const result = await GlideFt.profileSearch(client, "json_idx1", "*=>[KNN 2 @VEC $query_vec]", {params: [{key: "query_vec", value: vector}]});
304
+ * console.log(result); // Output:
305
+ * // result[0] contains `FT.SEARCH` response with the given query
306
+ * // result[1] contains profiling data as a `Record<string, number>`
307
+ * ```
308
+ */
309
+ static profileSearch(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: DecoderOption & FtSearchOptions & {
310
+ limited?: boolean;
311
+ }): Promise<[FtSearchReturnType, Record<string, number>]>;
312
+ /**
313
+ * Runs an aggregate query and collects performance profiling information.
314
+ *
315
+ * @param client - The client to execute the command.
316
+ * @param indexName - The index name.
317
+ * @param query - The text query to search.
318
+ * @param options - (Optional) See {@link FtAggregateOptions} and {@link DecoderOption}. Additionally:
319
+ * - `limited` (Optional) - Either provide a full verbose output or some brief version.
320
+ *
321
+ * @returns A two-element array. The first element contains results of the aggregate query being profiled, the
322
+ * second element stores profiling information.
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * // Example of running profile on an aggregate query
327
+ * const options: FtAggregateOptions = {
328
+ * loadFields: ["__key"],
329
+ * clauses: [
330
+ * {
331
+ * type: "GROUPBY",
332
+ * properties: ["@condition"],
333
+ * reducers: [
334
+ * {
335
+ * function: "TOLIST",
336
+ * args: ["__key"],
337
+ * name: "bicycles",
338
+ * },
339
+ * ],
340
+ * },
341
+ * ],
342
+ * };
343
+ * const result = await GlideFt.profileAggregate(client, "myIndex", "*", options);
344
+ * console.log(result); // Output:
345
+ * // result[0] contains `FT.AGGREGATE` response with the given query
346
+ * // result[1] contains profiling data as a `Record<string, number>`
347
+ * ```
348
+ */
349
+ static profileAggregate(client: GlideClient | GlideClusterClient, indexName: GlideString, query: GlideString, options?: DecoderOption & FtAggregateOptions & {
350
+ limited?: boolean;
351
+ }): Promise<[FtAggregateReturnType, Record<string, number>]>;
352
+ /**
353
+ * Adds an alias for an index. The new alias name can be used anywhere that an index name is required.
354
+ *
355
+ * @param client - The client to execute the command.
356
+ * @param indexName - The alias to be added to the index.
357
+ * @param alias - The index name for which the alias has to be added.
358
+ * @returns `"OK"`
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * // Example usage of FT.ALIASADD to add an alias for an index.
363
+ * await GlideFt.aliasadd(client, "index", "alias"); // "OK"
364
+ * ```
365
+ */
366
+ static aliasadd(client: GlideClient | GlideClusterClient, indexName: GlideString, alias: GlideString): Promise<"OK">;
367
+ /**
368
+ * Deletes an existing alias for an index.
369
+ *
370
+ * @param client - The client to execute the command.
371
+ * @param alias - The existing alias to be deleted for an index.
372
+ * @returns `"OK"`
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * // Example usage of FT.ALIASDEL to delete an existing alias.
377
+ * await GlideFt.aliasdel(client, "alias"); // "OK"
378
+ * ```
379
+ */
380
+ static aliasdel(client: GlideClient | GlideClusterClient, alias: GlideString): Promise<"OK">;
381
+ /**
382
+ * Updates an existing alias to point to a different physical index. This command only affects future references to the alias.
383
+ *
384
+ * @param client - The client to execute the command.
385
+ * @param alias - The alias name. This alias will now be pointed to a different index.
386
+ * @param indexName - The index name for which an existing alias has to updated.
387
+ * @returns `"OK"`
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * // Example usage of FT.ALIASUPDATE to update an alias to point to a different index.
392
+ * await GlideFt.aliasupdate(client, "newAlias", "index"); // "OK"
393
+ * ```
394
+ */
395
+ static aliasupdate(client: GlideClient | GlideClusterClient, alias: GlideString, indexName: GlideString): Promise<"OK">;
396
+ /**
397
+ * List the index aliases.
398
+ *
399
+ * @param client - The client to execute the command.
400
+ * @param options - (Optional) See {@link DecoderOption}.
401
+ * @returns A map of index aliases for indices being aliased.
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * // Example usage of FT._ALIASLIST to query index aliases
406
+ * const result = await GlideFt.aliaslist(client);
407
+ * console.log(result); // Output:
408
+ * //[{"key": "alias1", "value": "index1"}, {"key": "alias2", "value": "index2"}]
409
+ * ```
410
+ */
411
+ static aliaslist(client: GlideClient | GlideClusterClient, options?: DecoderOption): Promise<GlideRecord<GlideString>>;
412
+ }
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3
+ */
4
+ import { SortOrder } from "src/Commands";
5
+ import { GlideRecord, GlideString } from "../BaseClient";
6
+ interface BaseField {
7
+ /** The name of the field. */
8
+ name: GlideString;
9
+ /** An alias for field. */
10
+ alias?: GlideString;
11
+ }
12
+ /**
13
+ * Field contains any blob of data.
14
+ */
15
+ export type TextField = BaseField & {
16
+ /** Field identifier */
17
+ type: "TEXT";
18
+ };
19
+ /**
20
+ * Tag fields are similar to full-text fields, but they interpret the text as a simple list of
21
+ * tags delimited by a separator character.
22
+ *
23
+ * For HASH fields, separator default is a comma (`,`). For JSON fields, there is no default
24
+ * separator; you must declare one explicitly if needed.
25
+ */
26
+ export type TagField = BaseField & {
27
+ /** Field identifier */
28
+ type: "TAG";
29
+ /** Specify how text in the attribute is split into individual tags. Must be a single character. */
30
+ separator?: GlideString;
31
+ /** Preserve the original letter cases of tags. If set to `false`, characters are converted to lowercase by default. */
32
+ caseSensitive?: boolean;
33
+ };
34
+ /**
35
+ * Field contains a number.
36
+ */
37
+ export type NumericField = BaseField & {
38
+ /** Field identifier */
39
+ type: "NUMERIC";
40
+ };
41
+ /**
42
+ * Superclass for vector field implementations, contains common logic.
43
+ */
44
+ export type VectorField = BaseField & {
45
+ /** Field identifier */
46
+ type: "VECTOR";
47
+ /** Additional attributes to be passed with the vector field after the algorithm name. */
48
+ attributes: VectorFieldAttributesFlat | VectorFieldAttributesHnsw;
49
+ };
50
+ /**
51
+ * Base class for defining vector field attributes to be used after the vector algorithm name.
52
+ */
53
+ export interface VectorFieldAttributes {
54
+ /** Number of dimensions in the vector. Equivalent to `DIM` in the module API. */
55
+ dimensions: number;
56
+ /**
57
+ * The distance metric used in vector type field. Can be one of `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` in the module API.
58
+ */
59
+ distanceMetric: "L2" | "IP" | "COSINE";
60
+ /** Vector type. The only supported type is FLOAT32. */
61
+ type?: "FLOAT32";
62
+ /**
63
+ * Initial vector capacity in the index affecting memory allocation size of the index. Defaults to `1024`. Equivalent to `INITIAL_CAP` in the module API.
64
+ */
65
+ initialCap?: number;
66
+ }
67
+ /**
68
+ * Vector field that supports vector search by FLAT (brute force) algorithm.
69
+ *
70
+ * The algorithm is a brute force linear processing of each vector in the index, yielding exact
71
+ * answers within the bounds of the precision of the distance computations.
72
+ */
73
+ export type VectorFieldAttributesFlat = VectorFieldAttributes & {
74
+ algorithm: "FLAT";
75
+ };
76
+ /**
77
+ * Vector field that supports vector search by HNSM (Hierarchical Navigable Small World) algorithm.
78
+ *
79
+ * The algorithm provides an approximation of the correct answer in exchange for substantially
80
+ * lower execution times.
81
+ */
82
+ export type VectorFieldAttributesHnsw = VectorFieldAttributes & {
83
+ algorithm: "HNSW";
84
+ /**
85
+ * Number of maximum allowed outgoing edges for each node in the graph in each layer. Default is `16`, maximum is `512`.
86
+ * Equivalent to `M` in the module API.
87
+ */
88
+ numberOfEdges?: number;
89
+ /**
90
+ * Controls the number of vectors examined during index construction. Default value is `200`, Maximum value is `4096`.
91
+ * Equivalent to `EF_CONSTRUCTION` in the module API.
92
+ */
93
+ vectorsExaminedOnConstruction?: number;
94
+ /**
95
+ * Controls the number of vectors examined during query operations. Default value is `10`, Maximum value is `4096`.
96
+ * Equivalent to `EF_RUNTIME` in the module API.
97
+ */
98
+ vectorsExaminedOnRuntime?: number;
99
+ };
100
+ export type Field = TextField | TagField | NumericField | VectorField;
101
+ /**
102
+ * Represents the input options to be used in the {@link GlideFt.create | FT.CREATE} command.
103
+ * All fields in this class are optional inputs for FT.CREATE.
104
+ */
105
+ export interface FtCreateOptions {
106
+ /** The type of data to be indexed using FT.CREATE. */
107
+ dataType: "JSON" | "HASH";
108
+ /** The prefix of the key to be indexed. */
109
+ prefixes?: GlideString[];
110
+ }
111
+ /** Additional parameters for {@link GlideFt.aggregate | FT.AGGREGATE} command. */
112
+ export type FtAggregateOptions = {
113
+ /** Query timeout in milliseconds. */
114
+ timeout?: number;
115
+ /**
116
+ * {@link FtAggregateFilter | FILTER}, {@link FtAggregateLimit | LIMIT}, {@link FtAggregateGroupBy | GROUPBY},
117
+ * {@link FtAggregateSortBy | SORTBY} and {@link FtAggregateApply | APPLY} clauses, that can be repeated
118
+ * multiple times in any order and be freely intermixed. They are applied in the order specified,
119
+ * with the output of one clause feeding the input of the next clause.
120
+ */
121
+ clauses?: (FtAggregateLimit | FtAggregateFilter | FtAggregateGroupBy | FtAggregateSortBy | FtAggregateApply)[];
122
+ /**
123
+ * Query parameters, which could be referenced in the query by `$` sign, followed by
124
+ * the parameter name.
125
+ */
126
+ params?: GlideRecord<GlideString>;
127
+ } & ({
128
+ /** List of fields to load from the index. */
129
+ loadFields?: GlideString[];
130
+ /** `loadAll` and `loadFields` are mutually exclusive. */
131
+ loadAll?: never;
132
+ } | {
133
+ /** Option to load all fields declared in the index */
134
+ loadAll?: boolean;
135
+ /** `loadAll` and `loadFields` are mutually exclusive. */
136
+ loadFields?: never;
137
+ });
138
+ /** A clause for limiting the number of retained records. */
139
+ export interface FtAggregateLimit {
140
+ type: "LIMIT";
141
+ /** Starting point from which the records have to be retained. */
142
+ offset: number;
143
+ /** The total number of records to be retained. */
144
+ count: number;
145
+ }
146
+ /**
147
+ * A clause for filtering the results using predicate expression relating to values in each result.
148
+ * It is applied post query and relate to the current state of the pipeline.
149
+ */
150
+ export interface FtAggregateFilter {
151
+ type: "FILTER";
152
+ /** The expression to filter the results. */
153
+ expression: GlideString;
154
+ }
155
+ /** A clause for grouping the results in the pipeline based on one or more properties. */
156
+ export interface FtAggregateGroupBy {
157
+ type: "GROUPBY";
158
+ /** The list of properties to be used for grouping the results in the pipeline. */
159
+ properties: GlideString[];
160
+ /** The list of functions that handles the group entries by performing multiple aggregate operations. */
161
+ reducers: FtAggregateReducer[];
162
+ }
163
+ /**
164
+ * A clause for reducing the matching results in each group using a reduction function.
165
+ * The matching results are reduced into a single record.
166
+ */
167
+ export interface FtAggregateReducer {
168
+ /** The reduction function name for the respective group. */
169
+ function: string;
170
+ /** The list of arguments for the reducer. */
171
+ args: GlideString[];
172
+ /** User defined property name for the reducer. */
173
+ name?: GlideString;
174
+ }
175
+ /** A clause for sorting the pipeline up until the point of SORTBY, using a list of properties. */
176
+ export interface FtAggregateSortBy {
177
+ type: "SORTBY";
178
+ /** A list of sorting parameters for the sort operation. */
179
+ properties: FtAggregateSortProperty[];
180
+ /** The MAX value for optimizing the sorting, by sorting only for the n-largest elements. */
181
+ max?: number;
182
+ }
183
+ /** A single property for the {@link FtAggregateSortBy | SORTBY} clause. */
184
+ export interface FtAggregateSortProperty {
185
+ /** The sorting parameter. */
186
+ property: GlideString;
187
+ /** The order for the sorting. */
188
+ order: SortOrder;
189
+ }
190
+ /**
191
+ * A clause for applying a 1-to-1 transformation on one or more properties and stores the result
192
+ * as a new property down the pipeline or replaces any property using this transformation.
193
+ */
194
+ export interface FtAggregateApply {
195
+ type: "APPLY";
196
+ /** The transformation expression. */
197
+ expression: GlideString;
198
+ /** The new property name to store the result of apply. This name can be referenced by further operations down the pipeline. */
199
+ name: GlideString;
200
+ }
201
+ /**
202
+ * Represents the input options to be used in the FT.SEARCH command.
203
+ * All fields in this class are optional inputs for FT.SEARCH.
204
+ */
205
+ export type FtSearchOptions = {
206
+ /** Query timeout in milliseconds. */
207
+ timeout?: number;
208
+ /**
209
+ * Add a field to be returned.
210
+ * @param fieldIdentifier field name to return.
211
+ * @param alias optional alias for the field name to return.
212
+ */
213
+ returnFields?: {
214
+ fieldIdentifier: GlideString;
215
+ alias?: GlideString;
216
+ }[];
217
+ /**
218
+ * Query parameters, which could be referenced in the query by `$` sign, followed by
219
+ * the parameter name.
220
+ */
221
+ params?: GlideRecord<GlideString>;
222
+ } & ({
223
+ /**
224
+ * Configure query pagination. By default only first 10 documents are returned.
225
+ *
226
+ * @param offset Zero-based offset.
227
+ * @param count Number of elements to return.
228
+ */
229
+ limit?: {
230
+ offset: number;
231
+ count: number;
232
+ };
233
+ /** `limit` and `count` are mutually exclusive. */
234
+ count?: never;
235
+ } | {
236
+ /**
237
+ * Once set, the query will return only the number of documents in the result set without actually
238
+ * returning them.
239
+ */
240
+ count?: boolean;
241
+ /** `limit` and `count` are mutually exclusive. */
242
+ limit?: never;
243
+ });
244
+ export {};