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
+74-8Lines changed: 74 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -9,25 +9,91 @@ export class CreateIndexTool extends MongoDBToolBase {
9
9
protecteddescription="Create an index for a collection";
10
10
protectedargsShape={
11
11
...DbOperationArgs,
12
-
keys: z.object({}).catchall(z.custom<IndexDirection>()).describe("The index definition"),
13
12
name: z.string().optional().describe("The name of the index"),
13
+
definition: z
14
+
.discriminatedUnion("type",[
15
+
z.object({
16
+
type: z.literal("classic"),
17
+
keys: z.object({}).catchall(z.custom<IndexDirection>()).describe("The index definition"),
18
+
}),
19
+
z.object({
20
+
type: z.literal("vectorSearch"),
21
+
fields: z
22
+
.array(
23
+
z.object({
24
+
type: z
25
+
.enum(["vector","filter"])
26
+
.describe(
27
+
"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."
28
+
),
29
+
path: z
30
+
.string()
31
+
.describe(
32
+
"Name of the field to index. For nested fields, use dot notation to specify path to embedded fields"
33
+
),
34
+
numDimensions: z
35
+
.number()
36
+
.min(1)
37
+
.max(8192)
38
+
.describe(
39
+
"Number of vector dimensions that MongoDB Vector Search enforces at index-time and query-time"
40
+
),
41
+
similarity: z
42
+
.enum(["cosine","euclidean","dotProduct"])
43
+
.describe(
44
+
"Vector similarity function to use to search for top K-nearest neighbors. You can set this field only for vector-type fields."
45
+
),
46
+
quantization: z
47
+
.enum(["none","scalar","binary"])
48
+
.optional()
49
+
.default("none")
50
+
.describe(
51
+
"Type of automatic vector quantization for your vectors. Use this setting only if your embeddings are float or double vectors."
52
+
),
53
+
})
54
+
)
55
+
.describe(
56
+
"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."
57
+
),
58
+
}),
59
+
])
60
+
.describe(
61
+
"The index definition. Use 'classic' for standard indexes and 'vectorSearch' for vector search indexes"
0 commit comments