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
Copy file name to clipboardExpand all lines: src/tools/mongodb/create/createIndex.ts
+43-33Lines changed: 43 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -21,41 +21,51 @@ export class CreateIndexTool extends MongoDBToolBase {
21
21
type: z.literal("vectorSearch"),
22
22
fields: z
23
23
.array(
24
-
z.object({
25
-
type: z
26
-
.enum(["vector","filter"])
27
-
.describe(
28
-
"Field type to use to index fields for vector search. You must specify `vector` for fields that contain vector embeddings and `filter` for additional fields to filter on."
29
-
),
30
-
path: z
31
-
.string()
32
-
.describe(
33
-
"Name of the field to index. For nested fields, use dot notation to specify path to embedded fields"
34
-
),
35
-
numDimensions: z
36
-
.number()
37
-
.min(1)
38
-
.max(8192)
39
-
.describe(
40
-
"Number of vector dimensions that MongoDB Vector Search enforces at index-time and query-time"
41
-
),
42
-
similarity: z
43
-
.enum(["cosine","euclidean","dotProduct"])
44
-
.default("cosine")
45
-
.describe(
46
-
"Vector similarity function to use to search for top K-nearest neighbors. You can set this field only for vector-type fields."
47
-
),
48
-
quantization: z
49
-
.enum(["none","scalar","binary"])
50
-
.optional()
51
-
.default("none")
52
-
.describe(
53
-
"Type of automatic vector quantization for your vectors. Use this setting only if your embeddings are float or double vectors."
54
-
),
55
-
})
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
+
})
57
67
.describe(
58
-
"Definitions for the vector and filter fields to index, one definition per document. The fields array must contain at least one vector-type field definition."
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."
0 commit comments