-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
$search pipelines use `DocumentSourceInternalSearchIdLookUp` to retrieve the full documents given the _id s matched by mongot. DocumentSourceInternalSearchIdLookUp spins up a new query plan for each lookup. This query plan needs to survive shardVersion changes (e.g. due to a migration), so it cannot use a proper shard-versioned acquisition and instead operates in a sharding-unaware manner. $search works around this by manually injecting a shardFilter higher up the plan tree that will deal with filtering and also range preservation. While this may be correct, it does not conform to the ShardRole abstraction. We should change DocumentSourceInternalSearchIdLookUp to no longer execute unversioned plans.
One idea is to make DocumentSourceInternalSearchIdLookUp not use a new plan for each idLookup, and instead reuse a plan that is constructed during planning and later can be repositioned for each idLookup. (An additional benefit of this could be better performance)