{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vertesiahq/json-schema/vertesiahq-complex-search-payload-schema.json",
  "title": "ComplexSearchPayload",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vertesiahq-collections-api-openapi.yml#/components/schemas/ComplexSearchPayload",
  "type": "object",
  "properties": {
    "facets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/FacetSpec"
      }
    },
    "limit_facets": {
      "type": "boolean",
      "description": "If the facets should be limited to the current page of results. Defaults to false. When false, the facets are independent of the search results page."
    },
    "limit": {
      "type": "number"
    },
    "offset": {
      "type": "number"
    },
    "select": {
      "type": "string"
    },
    "all_revisions": {
      "type": "boolean"
    },
    "from_root": {
      "type": "string"
    },
    "sort": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SortOption"
      },
      "description": "Sort criteria. Multiple entries enable multi-field sorting (first entry is primary)."
    },
    "aggs": {
      "type": "object",
      "additionalProperties": true,
      "description": "Arbitrary Elasticsearch aggregation definitions. Ignored when search falls back to MongoDB."
    },
    "query": {
      "$ref": "#/$defs/ComplexSearchQuery"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "ComplexSearchQuery": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "status": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "limit": {
          "type": "number"
        },
        "offset": {
          "type": "number"
        },
        "id": {
          "type": "string"
        },
        "ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "createdFrom": {
          "type": "string"
        },
        "createdTo": {
          "type": "string"
        },
        "updatedFrom": {
          "type": "string"
        },
        "updatedTo": {
          "type": "string"
        },
        "location": {
          "type": "string"
        },
        "parent": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "types": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "all_revisions": {
          "type": "boolean"
        },
        "from_root": {
          "type": "string"
        },
        "vector": {
          "$ref": "#/$defs/VectorSearchQuery"
        },
        "full_text": {
          "type": "string",
          "description": "If present, do a full text search (snake_case version)."
        },
        "weights": {
          "$ref": "#/$defs/Record_SearchTypes_number"
        },
        "dynamic_scaling": {
          "$ref": "#/$defs/dynamicScalingTypes",
          "description": "dynamicScaling rescales the weights when a particular search type is not present in the results, per object. e.g. Weights of 5,3,2 will be treated as 0,3,2 if the first search type is not present in the results. Ignored when scoreAggregation is 'smart' Default is 'on'"
        },
        "score_aggregation": {
          "$ref": "#/$defs/scoreAggregationTypes",
          "description": "rrf: Reciprocal Rank Fusion rsf: Reciprocal Score Fusion smart: Our own algorithm (default and recommended)"
        },
        "match": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "additionalProperties": false,
      "description": "ComplexSearchQuery is used for full-text search and vector embedding search."
    },
    "EmbeddingSearchConfig": {
      "$ref": "#/$defs/EmbeddingTypeEnabledMap"
    },
    "EmbeddingTypeEnabledMap": {
      "type": "object",
      "properties": {
        "text": {
          "type": "boolean"
        },
        "image": {
          "type": "boolean"
        },
        "properties": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "FacetSpec": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Key the buckets are returned under. `total` is reserved for the match count that every facet response carries, and is rejected with a 400."
        },
        "field": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "field"
      ],
      "additionalProperties": false
    },
    "Record_SearchTypes_number": {
      "type": "object",
      "additionalProperties": {
        "type": "number"
      }
    },
    "SortOption": {
      "type": "object",
      "properties": {
        "field": {
          "type": "string",
          "description": "Field path to sort by (e.g. 'updated_at', 'name', 'properties.title')"
        },
        "order": {
          "$ref": "#/$defs/SortOrder",
          "description": "Sort direction. Defaults to 'desc'."
        }
      },
      "required": [
        "field"
      ],
      "additionalProperties": false
    },
    "SortOrder": {
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    },
    "VectorSearchQuery": {
      "type": "object",
      "properties": {
        "objectId": {
          "type": "string"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "text": {
          "type": "string"
        },
        "image": {
          "type": "string"
        },
        "config": {
          "$ref": "#/$defs/EmbeddingSearchConfig"
        }
      },
      "additionalProperties": false
    },
    "dynamicScalingTypes": {
      "type": "string",
      "enum": [
        "off",
        "on"
      ]
    },
    "scoreAggregationTypes": {
      "type": "string",
      "enum": [
        "rrf",
        "rsf",
        "smart"
      ]
    }
  }
}