# Copyright (C) 2023-present MongoDB, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the Server Side Public License, version 1,
# as published by MongoDB, Inc.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# Server Side Public License for more details.
#
# You should have received a copy of the Server Side Public License
# along with this program. If not, see
# <http://www.mongodb.com/licensing/server-side-public-license>.
#
# As a special exception, the copyright holders give permission to link the
# code of portions of this program with the OpenSSL library under certain
# conditions as described in each individual source file and distribute
# linked combinations including the program with the OpenSSL library. You
# must comply with the Server Side Public License in all respects for
# all of the code used other than as permitted herein. If you modify file(s)
# with this exception, you may extend this exception to your version of the
# file(s), but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version. If you delete this
# exception statement from all source files in the program, then also delete
# it in the license file.
#

global:
  cpp_namespace: "mongo"

imports:
  - "mongo/db/basic_types.idl"
  - "mongo/db/pipeline/visitors/docs_needed_bounds.idl"

structs:
  InternalSearchMongotRemoteSpec:
    description: Specification for a $_internalSearchMongotRemote stage given in the full, explicit format.
    # Because the specification is internal only, we permit extra fields. This avoids some upgrade/downngrade
    # concerns where a router may send a command to a node with fields not known by the node.
    strict: false
    fields:
      mongotQuery:
        description: The remote text search query.
        optional: false
        type: object_owned
      metadataMergeProtocolVersion:
        description: The mongot protocol version.
        optional: true
        type: int
      mergingPipeline:
        description: An optional pipeline to apply to the collection being unioned.
        optional: true
        type: array<object>
      # TODO SERVER-74941 We may be able to remove limit alongside docsRequested.
      limit:
        description: A limit copied from the merging part of the pipeline.
        optional: true
        type: long
      requiresSearchSequenceToken:
        description: "If true, mongot must return a searchSequenceToken with each document to allow the user to paginate results."
        default: false
        type: bool
      sortSpec:
        description: "The sort specification for this query."
        optional: true
        type: object
      mongotDocsRequested:
        description: "The number of documents that mongod requests mongot should return; mongot can choose to return more."
        optional: true
        type: long
      requiresSearchMetaCursor:
        description: >-
          Flag indicating whether or not the total user pipeline references the $$SEARCH_META variable. If false, we will
          ignore the metadata cursor returned from mongot and not establish a search metadata pipeline.
        default: true
        type: bool
      docsNeededBounds:
        description: Bounds to describe the minimum and maximum number of documents needed from mongot to satisfy the overall query.
        optional: true
        type: DocsNeededBounds
