Details
Description
This comment implies that the value of the SEARCH_META variable in the SBE RuntimeEnvironment can be set later on. That's not true. There is no downstream code to set the SEARCH_META value. And if there is a value for SEARCH_META inside ExpressionContext::variables, it will already have been set in the RuntimeEnvironment here.
After discussing with mihai.andrei, he explained that this code is actually a special case to handle non-$search queries which refer to SEARCH_META. We have an example test in the enterprise modules here. SEARCH_META is supposed to resolve to "missing" for non-$search queries. We currently deal with this in the SBE stage builder by establishing a missing value in the RuntimeEnvironment and then referring to this runtime environment slot later in the SBE plan. We should update the comment to correctly explain why this code exists.