There is a custom optimization for $search where we try to extract a limit for pushdown to the shards (similar for the $idLookup stage). This was put in place most likely because the generic limit pushdown was not triggering for search queries after the sharded facets project. Upon closer inspection, it seems possible that changing the stage constraints for $setVariableFromSubPipeline (added for sharded facets) to allow swapping with limit will enable the generic pushdown.
Also worth noting that as of SERVER-72934, we only create the $setVariableFromSubPipeline stage if there's a reference to SEARCH_META, so we should test both scenarios.
- is depended on by
-
SERVER-81083 Remove legacy 'limit' parsing support from $search stages
- Open