-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
There are multiple DocumentSource types that are present in a mongot involved query. Namely, DocumentSourceSearch, DocumentSourceVectorSearch and DocumentSourceSearchMeta.
All of these DocumentSources have some common logic related to communicating with mongot. This mongot related communication is consolidated in DocumentSourceInternalSearchMongotRemote.
Right now all these aforementioned document sources become a DocumentSourceInternalSearchMongotRemote upon desugaring (optionally with a DocumentSourceInternalSearchIdLookup, for non stored source queries). This leads to awkward logic where an instance of DocumentSourceInternalSearchMongotRemote could really be a $search / $vectorSearch / $searchMeta and may need to compute which stage its running for to do specific logic for that stage.
Of course the proper, generic, solution for this type of problem is to use class inheritance. We should still have a DocumentSourceInternalSearchMongotRemote, but instead as a (possibly virtual) base class, which DocumentSourceSearch, DocumentSourceVectorSearch, and DocumentSourceSearchMeta inherit from. Then stage specific logic can be placed inside each stages specific document source.
Also be sure that after this stage, desugaring of mongot related stages still works properly, with and without stored source.
Also, see this brainstorming document previously put together on this topic