-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathGlideFtOptions.ts
More file actions
113 lines (104 loc) · 3.62 KB
/
GlideFtOptions.ts
File metadata and controls
113 lines (104 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/
import { GlideString } from "../BaseClient";
interface BaseField {
/** The name of the field. */
name: GlideString;
/** An alias for field. */
alias?: GlideString;
}
/**
* If the field contains any blob of data.
*/
export type TextField = BaseField & {
/** Field identifier */
type: "TEXT";
};
/**
* If the field contains a tag field.
*/
export type TagField = BaseField & {
/** Field identifier */
type: "TAG";
/** Specify how text in the attribute is split into individual tags. Must be a single character. */
separator?: GlideString;
/** Preserve the original letter cases of tags. If set to False, characters are converted to lowercase by default. */
caseSensitive?: boolean;
};
/**
* If the field contains a number.
*/
export type NumericField = BaseField & {
/** Field identifier */
type: "NUMERIC";
};
/**
* If the field is a vector field that supports vector search.
*/
export type VectorField = BaseField & {
/** Field identifier */
type: "VECTOR";
/** Additional attributes to be passed with the vector field after the algorithm name. */
attributes: VectorFieldAttributesFlat | VectorFieldAttributesHnsw;
};
/**
* Base class for defining vector field attributes to be used after the vector algorithm name.
*/
export interface VectorFieldAttributes {
/** Number of dimensions in the vector. Equivalent to DIM in the option. */
dimension: number;
/**
* The distance metric used in vector type field. Can be one of [L2 | IP | COSINE].
*/
distanceMetric: "L2" | "IP" | "COSINE";
/** Vector type. The only supported type is FLOAT32. */
type: "FLOAT32";
/**
* Initial vector capacity in the index affecting memory allocation size of the index. Defaults to 1024.
*/
initialCap?: number;
}
export type VectorFieldAttributesFlat = VectorFieldAttributes & {
/**
* Vector field that supports vector search by FLAT (brute force) algorithm.
* The algorithm is a brute force linear processing of each vector in the index, yielding exact
* answers within the bounds of the precision of the distance computations.
*/
algorithm: "FLAT";
};
export type VectorFieldAttributesHnsw = VectorFieldAttributes & {
/**
* Vector field that supports vector search by HNSM (Hierarchical Navigable Small
* World) algorithm.
* The algorithm provides an approximation of the correct answer in exchange for substantially
* lower execution times.
*/
algorithm: "HNSW";
/**
* Number of maximum allowed outgoing edges for each node in the graph in each layer. Default is 16, maximum is 512.
* Equivalent to the `m` attribute.
*/
numberOfEdges?: number;
/**
* Controls the number of vectors examined during index construction. Default value is 200, Maximum value is 4096.
* Equivalent to the `efContruction` attribute.
*/
vectorsExaminedOnConstruction?: number;
/**
* Controls the number of vectors examined during query operations. Default value is 10, Maximum value is 4096.
* Equivalent to the `efRuntime` attribute.
*/
vectorsExaminedOnRuntime?: number;
};
export type Field = TextField | TagField | NumericField | VectorField;
/**
* Represents the input options to be used in the FT.CREATE command.
* All fields in this class are optional inputs for FT.CREATE.
*/
export interface FtCreateOptions {
/** The type of data to be indexed using FT.CREATE. */
dataType: "JSON" | "HASH";
/** The prefix of the key to be indexed. */
prefixes?: GlideString[];
}