-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Most $search and $vectorSearch pipelines involve a step to fetch the full document for subsequent use in the pipeline. We could do better to attempt to fetch only the fields necessary for the rest of the pipeline so that we can try to avoid a FETCH stage and stick to data present in indexes. For example:
// Could use only the _id index: db.fts.aggregate({ $search: { text: {path: "description", value: "example"}} }, { $project: { _id: 1} }) // Could use an index on fields '_id, a, b, c'. db.fts.aggregate({ $search: { text: {path: "description", value: "example"}} }, { $group: {_id: "$a", /* do something with 'b, c' */} })