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/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