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",
62
+
})
63
+
.describe(
64
+
"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."
65
+
),
66
+
})
67
+
.describe("Definition for a Vector Search index.");
68
+
69
+
privateatlasSearchIndexDefinition=z
70
+
.object({
71
+
type: z.literal("search"),
72
+
analyzer: z
73
+
.string()
74
+
.optional()
75
+
.default("lucene.standard")
76
+
.describe(
77
+
"The analyzer to use for the index. Can be one of the built-in lucene analyzers (`lucene.standard`, `lucene.simple`, `lucene.whitespace`, `lucene.keyword`), a language-specific analyzer, such as `lucene.cjk` or `lucene.czech`, or a custom analyzer defined in the Atlas UI."
78
+
),
79
+
mappings: z
80
+
.object({
81
+
dynamic: z
82
+
.boolean()
83
+
.optional()
84
+
.default(false)
85
+
.describe(
86
+
"Enables or disables dynamic mapping of fields for this index. If set to true, Atlas Search recursively indexes all dynamically indexable fields. If set to false, you must specify individual fields to index using mappings.fields."
87
+
),
88
+
fields: z
89
+
.record(
90
+
z.string().describe("The field name"),
91
+
z
92
+
.object({
93
+
type: z
94
+
.enum([
95
+
"autocomplete",
96
+
"boolean",
97
+
"date",
98
+
"document",
99
+
"embeddedDocuments",
100
+
"geo",
101
+
"number",
102
+
"objectId",
103
+
"string",
104
+
"token",
105
+
"uuid",
106
+
])
107
+
.describe("The field type"),
108
+
})
109
+
.passthrough()
50
110
.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
-
.strict()
55
-
.describe("Definition for a field that contains vector embeddings."),
message: "At least one vector field must be defined",
61
-
})
62
-
.describe(
63
-
"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."
64
-
),
65
-
});
111
+
"The field index definition. It must contain the field type, as well as any additional options for that field type."
112
+
)
113
+
)
114
+
.optional()
115
+
.describe("The field mapping definitions. If `dynamic` is set to `false`, this is required."),
"Either `dynamic` must be `true` and `fields` empty or `dynamic` must be `false` and at least one field must be defined in `fields`",
120
+
})
121
+
.describe(
122
+
"Document describing the index to create. Either `dynamic` must be `true` and `fields` empty or `dynamic` must be `false` and at least one field must be defined in the `fields` document."
`The index definition. Use 'classic' for standard indexes${this.isFeatureEnabled("search") ? " and 'vectorSearch' for vector search indexes" : ""}.`
154
+
`The index definition. Use 'classic' for standard indexes${this.isFeatureEnabled("search") ? ", 'vectorSearch' for vector search indexes, and 'search' for Atlas Search (lexical) indexes" : ""}.`
84
155
),
85
156
};
86
157
@@ -130,6 +201,26 @@ export class CreateIndexTool extends MongoDBToolBase {
Copy file name to clipboardExpand all lines: src/tools/mongodb/read/aggregate.ts
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@ import {
20
20
21
21
constpipelineDescriptionWithVectorSearch=`\
22
22
An array of aggregation stages to execute.
23
-
\`$vectorSearch\` **MUST** be the first stage of the pipeline, or the first stage of a \`$unionWith\` subpipeline.
23
+
If the user has asked for a vector search, \`$vectorSearch\` **MUST** be the first stage of the pipeline, or the first stage of a \`$unionWith\` subpipeline.
24
+
If the user has asked for lexical/Atlas search, use \`$search\` instead of \`$text\`.
24
25
### Usage Rules for \`$vectorSearch\`
25
26
- **Unset embeddings:**
26
27
Unless the user explicitly requests the embeddings, add an \`$unset\` stage **at the end of the pipeline** to remove the embedding field and avoid context limits. **The $unset stage in this situation is mandatory**.
@@ -29,9 +30,12 @@ If the user requests additional filtering, include filters in \`$vectorSearch.fi
29
30
NEVER include fields in $vectorSearch.filter that are not part of the vector index.
30
31
- **Post-filtering:**
31
32
For all remaining filters, add a $match stage after $vectorSearch.
32
-
### Note to LLM
33
33
- If unsure which fields are filterable, use the collection-indexes tool to determine valid prefilter fields.
34
-
- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.\
34
+
- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.
35
+
36
+
### Usage Rules for \`$search\`
37
+
- Include the index name, unless you know for a fact there's a default index. If unsure, use the collection-indexes tool to determine the index name.
38
+
- The \`$search\` stage supports multiple operators, such as 'autocomplete', 'text', 'geoWithin', and others. Choose the approprate operator based on the user's query. If unsure of the exact syntax, consult the MongoDB Atlas Search documentation, which can be found here: https://www.mongodb.com/docs/atlas/atlas-search/operators-and-collectors/
35
39
`;
36
40
37
41
constgenericPipelineDescription="An array of aggregation stages to execute.";
0 commit comments