You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
message: "At least one vector field must be defined",
59
+
})
60
+
.describe(
61
+
"Definitions for the vector and filter fields to index, one definition per document. You must specify `vector` for fields that contain vector embeddings and `filter` for additional fields to filter on. At least one vector-type field definition is required."
62
+
),
63
+
});
64
+
7
65
exportclassCreateIndexToolextendsMongoDBToolBase{
8
66
publicname="create-index";
9
67
protecteddescription="Create an index for a collection";
10
-
protectedargsShape={
11
-
...DbOperationArgs,
12
-
name: z.string().optional().describe("The name of the index"),
13
-
definition: z
14
-
.array(
15
-
z.discriminatedUnion("type",[
16
-
z.object({
17
-
type: z.literal("classic"),
18
-
keys: z.object({}).catchall(z.custom<IndexDirection>()).describe("The index definition"),
19
-
}),
20
-
z.object({
21
-
type: z.literal("vectorSearch"),
22
-
fields: z
23
-
.array(
24
-
z.discriminatedUnion("type",[
25
-
z.object({
26
-
type: z.literal("filter"),
27
-
path: z
28
-
.string()
29
-
.describe(
30
-
"Name of the field to index. For nested fields, use dot notation to specify path to embedded fields"
31
-
),
32
-
}),
33
-
z.object({
34
-
type: z.literal("vector"),
35
-
path: z
36
-
.string()
37
-
.describe(
38
-
"Name of the field to index. For nested fields, use dot notation to specify path to embedded fields"
39
-
),
40
-
numDimensions: z
41
-
.number()
42
-
.min(1)
43
-
.max(8192)
44
-
.describe(
45
-
"Number of vector dimensions that MongoDB Vector Search enforces at index-time and query-time"
46
-
),
47
-
similarity: z
48
-
.enum(["cosine","euclidean","dotProduct"])
49
-
.default("cosine")
50
-
.describe(
51
-
"Vector similarity function to use to search for top K-nearest neighbors. You can set this field only for vector-type fields."
52
-
),
53
-
quantization: z
54
-
.enum(["none","scalar","binary"])
55
-
.optional()
56
-
.default("none")
57
-
.describe(
58
-
"Type of automatic vector quantization for your vectors. Use this setting only if your embeddings are float or double vectors."
message: "At least one vector field must be defined",
66
-
})
67
-
.describe(
68
-
"Definitions for the vector and filter fields to index, one definition per document. You must specify `vector` for fields that contain vector embeddings and `filter` for additional fields to filter on. At least one vector-type field definition is required."
69
-
),
70
-
}),
71
-
])
72
-
)
73
-
.describe(
74
-
"The index definition. Use 'classic' for standard indexes and 'vectorSearch' for vector search indexes"
0 commit comments