[M1 - Search Extension] Implement create_document_results_and_metadata host service

XMLWordPrintableJSON

    • Query Integration
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      Implement the create_document_results_and_metadata host service function, following the same pattern as create_id_lookup. Includes the C API declaration, host adapter implementation, and SDK wrapper. The DPL callback parameter is deferred to M2.

      Background

      During expand(), an extension calls this host service to construct a $_documentResultsAndMetadata AST node. The extension passes the source stage spec as BSON and the metadata variable name; the host parses it, builds a LiteParsedDocumentResultsAndMetadata, wraps it in a HostAggStageAstNodeAdapter, and returns an AST node handle.

      Scope of Work

      • api.h: add create_document_results_and_metadata to MongoExtensionHostServicesVTable:
        MongoExtensionStatus* (*create_document_results_and_metadata)(
            MongoExtensionByteView bsonSpec,
            MongoExtensionByteView metadataVarName,
            MongoExtensionAggStageAstNode** node);
        
      • host_services_adapter.cpp: implement the function — parse bsonSpec into source stage, build LiteParsedDocumentResultsAndMetadata, wrap in HostAggStageAstNodeAdapter, return handle
      • SDK (host_services.h): add createDocumentResultsAndMetadata(BSONObj sourceSpec, StringData varName) wrapper on HostServicesAPI
      • Note: The DPL callback (MongoExtensionDocResultsDPLCallback) is not included here — it is part of M2.

      Acceptance Criteria

      • Extension can call createDocumentResultsAndMetadata during expand() and receive a valid AST node handle
      • Host correctly builds LiteParsedDocumentResultsAndMetadata from the BSON spec
      • Unit tests cover round-trip: extension calls service, host parses, AST node is valid

            Assignee:
            Josh Siegel
            Reporter:
            Daniel Segel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: