{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sap-btp/json-schema/sap-btp-retrieval-search-input-schema.json",
  "title": "RetrievalSearchInput",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sap-btp-document-grounding-openapi.yml#/components/schemas/RetrievalSearchInput",
  "properties": {
    "query": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "title": "Query",
      "description": "Query string"
    },
    "filters": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/RetrievalSearchFilter"
          },
          {
            "$ref": "#/$defs/RetrievalVectorSearchFilter"
          }
        ]
      },
      "title": "Filters"
    },
    "postProcessing": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "strategy",
          "inputs"
        ],
        "properties": {
          "id": {
            "description": "New ID for each PostProcessingOperation.",
            "default": "ae9eee48-4671-4321-a3e5-640adaaf26ae",
            "type": [
              "string",
              "null"
            ]
          },
          "maxChunkCount": {
            "description": "Maximum number of chunks to be retained in final PerSearchFilterResult.",
            "type": [
              "integer",
              "null"
            ],
            "exclusiveMinimum": true,
            "minimum": 0,
            "maximum": 10000000,
            "default": 5
          },
          "strategy": {
            "description": "Merging and scoring strategy to derive final PerSearchFilterResult.",
            "oneOf": [
              {
                "$ref": "#/$defs/MergeStrategyScoreReuse"
              },
              {
                "$ref": "#/$defs/MergeStrategyReranker"
              }
            ]
          },
          "inputs": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/$defs/PostProcessingObjectReference"
                },
                {
                  "$ref": "#/$defs/PostProcessingOperation"
                }
              ]
            }
          }
        }
      },
      "description": "List of operations to be performed across PerFilterSearchResults.",
      "default": []
    }
  },
  "type": "object",
  "required": [
    "query",
    "filters"
  ],
  "$defs": {
    "BoostingScoreComputationStrategy": {
      "enum": [
        "match_count",
        "embedding"
      ],
      "type": "string",
      "title": "BoostingScoreComputationStrategy"
    },
    "BoostingScoringConfiguration": {
      "properties": {
        "enabled": {
          "type": [
            "boolean",
            "null"
          ],
          "default": true,
          "description": "Enable metadata-based boosting."
        },
        "metadata": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "required": [
              "key",
              "value",
              "weight"
            ],
            "properties": {
              "key": {
                "type": "string",
                "maxLength": 1024
              },
              "value": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 1024
                }
              },
              "scope": {
                "type": "string",
                "enum": [
                  "repository",
                  "document",
                  "chunk"
                ],
                "default": "document"
              },
              "weight": {
                "type": "integer"
              }
            }
          },
          "default": []
        },
        "weight": {
          "type": [
            "integer",
            "null"
          ],
          "default": 1,
          "description": "Contribution to final score."
        },
        "scoreComputationStrategy": {
          "description": "How the similarity between document metadata and boosted key-value pairs is computed.",
          "$ref": "#/$defs/BoostingScoreComputationStrategy",
          "nullable": true,
          "default": "match_count"
        }
      },
      "type": "object",
      "title": "BoostingScoringConfiguration"
    },
    "DataRepositoryType": {
      "description": "Only include DataRepositories with the given type.",
      "type": "string",
      "enum": [
        "vector",
        "help.sap.com",
        "remote:dg"
      ],
      "title": "DataRepositoryType"
    },
    "DenseRetrievalScoringConfiguration": {
      "properties": {
        "enabled": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Enable dense retrieval.",
          "default": true
        },
        "weight": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Contribution to final score.",
          "default": 1
        }
      },
      "type": "object",
      "title": "DenseRetrievalScoringConfiguration"
    },
    "KeyWordRetrievalScoringConfiguration": {
      "properties": {
        "enabled": {
          "type": [
            "boolean",
            "null"
          ],
          "default": true,
          "description": "Enable dense retrieval."
        },
        "weight": {
          "type": [
            "integer",
            "null"
          ],
          "default": 1,
          "description": "Contribution to final score."
        },
        "extractKeyWordsFromQuery": {
          "type": [
            "boolean",
            "null"
          ],
          "default": false,
          "description": "Extract Keywords from Query."
        }
      },
      "type": "object",
      "title": "KeyWordRetrievalScoringConfiguration"
    },
    "MergeStrategyReranker": {
      "properties": {
        "type": {
          "$ref": "#/$defs/MergeStrategyType",
          "nullable": true,
          "default": "reranker"
        },
        "model": {
          "description": "The RerankerModel to use.",
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "cohere-3.5"
          ],
          "title": "RerankerModel",
          "default": "cohere-3.5"
        },
        "boosting": {
          "description": "Key-value pairs to be included in the ranking process, to boost related chunks according to chunk content and metadata, if includeMetaData is true.",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "required": [
              "key",
              "value",
              "scope"
            ],
            "properties": {
              "key": {
                "type": "string",
                "maxLength": 1024
              },
              "value": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 1024
                }
              },
              "scope": {
                "type": "array",
                "description": "PerFilterSearchResult ID or a new ID for each PostProcessingOperation.",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "includeAllMetaData": {
          "description": "If true, document and chunk metadata are sent to the reranker LLM along with the text content of the chunk.",
          "type": [
            "boolean",
            "null"
          ],
          "default": false
        }
      },
      "type": "object",
      "title": "MergeStrategyReranker",
      "description": "The MergeStrategyReranker will call a reranker LLM to merge the given PerFilterSearchResult instances. This strategy adds latency, but yields good results."
    },
    "MergeStrategyScoreReuse": {
      "properties": {
        "type": {
          "description": "The type of merge strategy.",
          "$ref": "#/$defs/MergeStrategyType",
          "nullable": true,
          "default": "scoreReuse"
        }
      },
      "type": "object",
      "title": "MergeStrategyScoreReuse",
      "description": "The MergeStrategyScoreReuse merges the given PerFilterSearchResult instances according to the scores returned by the downstream retrieval process. It is important that the scores are comparable, meaning they should come from the same embedding model or reranker model."
    },
    "MergeStrategyType": {
      "enum": [
        "reranker",
        "scoreReuse",
        "reciprocalRankFusion",
        "random"
      ],
      "type": "string",
      "title": "MergeStrategyType"
    },
    "PostProcessingObjectReference": {
      "properties": {
        "id": {
          "description": "PerFilterSearchResult ID or PostProcessingOperation ID.",
          "type": [
            "string",
            "null"
          ],
          "default": "6d3eeafd-f3db-4e8e-949a-0e40e50eab64"
        }
      },
      "type": "object",
      "title": "PostProcessingObjectReference"
    },
    "PostProcessingOperation": {
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "New ID for each PostProcessingOperation.",
          "default": "ae9eee48-4671-4321-a3e5-640adaaf26ae",
          "title": "Id"
        },
        "maxChunkCount": {
          "title": "Maxchunkcount",
          "description": "Maximum number of chunks to be retained in final PerSearchFilterResult.",
          "default": 5,
          "type": [
            "integer",
            "null"
          ],
          "exclusiveMinimum": true,
          "minimum": 0,
          "maximum": 10000000
        },
        "strategy": {
          "title": "Strategy",
          "description": "Merging and scoring strategy to derive final PerSearchFilterResult.",
          "oneOf": [
            {
              "$ref": "#/$defs/MergeStrategyScoreReuse"
            },
            {
              "$ref": "#/$defs/MergeStrategyReranker"
            }
          ]
        },
        "inputs": {
          "title": "Inputs",
          "type": "array",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/PostProcessingObjectReference"
              },
              {
                "$ref": "#/$defs/PostProcessingOperation"
              }
            ]
          }
        }
      },
      "type": "object",
      "required": [
        "strategy",
        "inputs"
      ],
      "title": "PostProcessingOperation"
    },
    "RetrievalBinaryBooleanFilter": {
      "properties": {
        "operator": {
          "type": "string",
          "title": "Operator",
          "enum": [
            "and",
            "or"
          ]
        },
        "left": {
          "title": "Left",
          "anyOf": [
            {
              "$ref": "#/$defs/RetrievalBinaryBooleanFilter"
            },
            {
              "$ref": "#/$defs/RetrievalScopedKeyValueListPair"
            }
          ]
        },
        "right": {
          "title": "Right",
          "anyOf": [
            {
              "$ref": "#/$defs/RetrievalBinaryBooleanFilter"
            },
            {
              "$ref": "#/$defs/RetrievalScopedKeyValueListPair"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "operator",
        "left",
        "right"
      ],
      "title": "RetrievalBinaryBooleanFilter"
    },
    "RetrievalKeyValueListPair": {
      "properties": {
        "key": {
          "type": "string",
          "maxLength": 1024,
          "title": "Key"
        },
        "value": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1024
          },
          "title": "Value"
        }
      },
      "type": "object",
      "required": [
        "key",
        "value"
      ],
      "title": "RetrievalKeyValueListPair"
    },
    "RetrievalScopedKeyValueListPair": {
      "properties": {
        "key": {
          "type": "string",
          "maxLength": 1024,
          "title": "Key"
        },
        "value": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1024
          },
          "title": "Value"
        },
        "scope": {
          "type": "string",
          "title": "Scope",
          "enum": [
            "repository",
            "document",
            "chunk"
          ],
          "default": "document"
        }
      },
      "type": "object",
      "required": [
        "key",
        "value"
      ],
      "title": "RetrievalScopedKeyValueListPair"
    },
    "RetrievalSearchConfiguration": {
      "default": {},
      "minProperties": 0,
      "maxProperties": 2,
      "properties": {
        "maxChunkCount": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "exclusiveMinimum": true,
          "maximum": 10000000,
          "title": "Maxchunkcount",
          "description": "Maximum number of chunks to be returned. Cannot be used with 'maxDocumentCount'."
        },
        "maxDocumentCount": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "exclusiveMinimum": true,
          "maximum": 10000000,
          "title": "Maxdocumentcount",
          "description": "[Only supports 'vector' dataRepositoryType] - Maximum number of documents to be returned. Cannot be used with 'maxChunkCount'. If maxDocumentCount is given, then only one chunk per document is returned."
        }
      },
      "type": [
        "object",
        "null"
      ],
      "title": "RetrievalSearchConfiguration"
    },
    "RetrievalSearchDocumentKeyValueListPair": {
      "properties": {
        "key": {
          "type": "string",
          "maxLength": 1024,
          "title": "Key"
        },
        "value": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1024
          },
          "title": "Value"
        },
        "selectMode": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/RetrievalSearchSelectOptionEnum"
          },
          "title": "Selectmode",
          "description": "Select mode for search filters"
        }
      },
      "type": "object",
      "required": [
        "key",
        "value"
      ],
      "title": "RetrievalSearchDocumentKeyValueListPair"
    },
    "RetrievalSearchFilter": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Identifier of this RetrievalSearchFilter - unique per request."
        },
        "searchConfiguration": {
          "nullable": true,
          "$ref": "#/$defs/RetrievalSearchConfiguration",
          "default": {}
        },
        "dataRepositories": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Datarepositories",
          "description": "Specify ['*'] to search across all DataRepositories or give a specific list of DataRepository ids.",
          "default": [
            "*"
          ]
        },
        "dataRepositoryType": {
          "$ref": "#/$defs/DataRepositoryType",
          "description": "Only include DataRepositories with the given type."
        },
        "remoteName": {
          "description": "Destination Name of remote instance.",
          "type": [
            "string",
            "null"
          ]
        },
        "dataRepositoryMetadata": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RetrievalKeyValueListPair"
          },
          "title": "Datarepositorymetadata",
          "description": "Restrict DataRepositories considered during search to those annotated with the given metadata. Useful when combined with dataRepositories=['*']",
          "default": []
        },
        "documentMetadata": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RetrievalSearchDocumentKeyValueListPair"
          },
          "title": "Documentmetadata",
          "description": "Restrict documents considered during search to those annotated with the given metadata.",
          "default": []
        },
        "chunkMetadata": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RetrievalKeyValueListPair"
          },
          "title": "Chunkmetadata",
          "description": "Restrict chunks considered during search to those with the given metadata.",
          "default": []
        }
      },
      "type": "object",
      "required": [
        "id",
        "dataRepositoryType"
      ],
      "title": "RetrievalSearchFilter",
      "description": "Limit scope of search to certain DataRepositories, Documents or Chunks."
    },
    "RetrievalSearchSelectOptionEnum": {
      "type": "string",
      "enum": [
        "ignoreIfKeyAbsent"
      ],
      "title": "RetrievalSearchSelectOptionEnum"
    },
    "RetrievalVectorSearchFilter": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Identifier of this RetrievalSearchFilter - unique per request."
        },
        "searchConfiguration": {
          "$ref": "#/$defs/RetrievalSearchConfiguration",
          "nullable": true,
          "default": {}
        },
        "dataRepositories": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Datarepositories",
          "description": "Specify ['*'] to search across all DataRepositories or give a specific list of DataRepository ids.",
          "default": [
            "*"
          ]
        },
        "dataRepositoryType": {
          "$ref": "#/$defs/DataRepositoryType",
          "nullable": true,
          "default": "vector"
        },
        "remoteName": {
          "description": "Destination Name of remote instance.",
          "type": [
            "string",
            "null"
          ]
        },
        "dataRepositoryMetadata": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RetrievalKeyValueListPair"
          },
          "title": "Datarepositorymetadata",
          "description": "Restrict DataRepositories considered during search to those annotated with the given metadata. Useful when combined with dataRepositories=['*']",
          "default": []
        },
        "documentMetadata": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RetrievalSearchDocumentKeyValueListPair"
          },
          "title": "Documentmetadata",
          "description": "Restrict documents considered during search to those annotated with the given metadata.",
          "default": []
        },
        "chunkMetadata": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RetrievalKeyValueListPair"
          },
          "title": "Chunkmetadata",
          "description": "Restrict chunks considered during search to those with the given metadata.",
          "default": []
        },
        "filter": {
          "anyOf": [
            {
              "$ref": "#/$defs/RetrievalBinaryBooleanFilter"
            },
            {
              "$ref": "#/$defs/RetrievalScopedKeyValueListPair"
            }
          ],
          "nullable": true,
          "description": "Filter to apply on the search results. This cannot be used together with 'documentMetadata'. The depth of the filter must not exceed 5 levels."
        },
        "scoringConfiguration": {
          "$ref": "#/$defs/VectorScoringConfiguration",
          "nullable": true,
          "description": "Scoring configuration for retrieval and ranking.",
          "default": {
            "denseRetrieval": {
              "enabled": true,
              "weight": 1
            },
            "keywordRetrieval": {
              "enabled": true,
              "extractKeyWordsFromQuery": false,
              "weight": 1
            },
            "boosting": {
              "enabled": true,
              "metadata": [],
              "scoreComputationStrategy": "match_count",
              "weight": 1
            },
            "aggregationStrategy": "weighted_average"
          }
        }
      },
      "type": "object",
      "required": [
        "id"
      ],
      "title": "RetrievalVectorSearchFilter"
    },
    "ScoresAggregationStrategy": {
      "enum": [
        "weighted_average",
        "rrf",
        "weighted_rrf"
      ],
      "type": "string",
      "title": "ScoresAggregationStrategy"
    },
    "VectorScoringConfiguration": {
      "properties": {
        "denseRetrieval": {
          "$ref": "#/$defs/DenseRetrievalScoringConfiguration",
          "nullable": true,
          "default": {
            "enabled": true,
            "weight": 1
          }
        },
        "keywordRetrieval": {
          "$ref": "#/$defs/KeyWordRetrievalScoringConfiguration",
          "nullable": true,
          "default": {
            "enabled": true,
            "weight": 1,
            "extractKeyWordsFromQuery": false
          }
        },
        "boosting": {
          "$ref": "#/$defs/BoostingScoringConfiguration",
          "nullable": true,
          "default": {
            "enabled": true,
            "metadata": [],
            "weight": 1,
            "scoreComputationStrategy": "match_count"
          }
        },
        "scoreThreshold": {
          "title": "Scorethreshold",
          "description": "Minimum chunk score threshold.",
          "type": [
            "number",
            "null"
          ]
        },
        "aggregationStrategy": {
          "description": "Methodology to calculate the final aggregate score.",
          "$ref": "#/$defs/ScoresAggregationStrategy",
          "nullable": true,
          "default": "weighted_average"
        }
      },
      "type": "object",
      "title": "VectorScoringConfiguration"
    }
  }
}