{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/adobe/json-schema/adobe-content-source-search-request-schema.json",
  "title": "ContentSourceSearchRequest",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/adobe-aem-content-ai-openapi.yml#/components/schemas/ContentSourceSearchRequest",
  "type": "object",
  "required": [
    "contentSource"
  ],
  "properties": {
    "contentSource": {
      "allOf": [
        {
          "$ref": "#/$defs/ContentSourceSearchConfig"
        }
      ],
      "description": "Config for the content source to search in"
    },
    "query": {
      "allOf": [
        {
          "$ref": "#/$defs/ContentAIQuery"
        }
      ],
      "description": "Content AI query. This describes the the search query to be executed.\n- If you need to get only the search results, use just the `query` field along with the `queryOptions` (if needed).\n- Use both `query` and `aggregates` to get search results with aggregations calculated on them.\n- To get only the aggregations, set the `limit` in `queryOptions.pagination` to 0, if you specify a `query` with `aggregates`,\n  you will get the aggregations calculated on the results of the `query`, otherwise, they will be calculated on all the documents\n  in the index.\n- Not supplying either will result in a `Bad Request`.\n"
    },
    "boostQuery": {
      "allOf": [
        {
          "$ref": "#/$defs/ContentAIQuery"
        }
      ],
      "description": "Content AI boost query. This query will be used to boost the relevance score of matched documents using the `query` field.\nUse this if you need to influence the relevance of matched documents based on certain criteria. This can only be provided\nwhen a `query` is also provided. Request would fail if this is provided without a `query`.\n"
    },
    "queryOptions": {
      "allOf": [
        {
          "$ref": "#/$defs/ContentAIQueryOptions"
        }
      ],
      "description": "Content AI query options. These can be used to control various aspects of the query like pagination, sort etc.\n"
    },
    "aggregates": {
      "description": "Aggregates are useful for analysing the indexed data in your Content AI index.\nThese include buckets and metric calculation. These are calculated on the\nsearch results and can be used in data analytics and also to filter content (using buckets).\nIn order to get just the aggregate results without the actual documents,\nset the `limit` in `queryOptions.pagination` to 0.\n\nMultiple aggregations can be requested in this list. Each item in this list can specify the `field` and the `type`\nof aggregation being requested.\nBased on the `type` of aggregates requested, additional properties can/should be specified.\n\nThe maximum number of buckets returned for a single search across all the aggregates is not unlimited.\nUnderlying implementation can fail a request if the number of buckets to be returned is too high.\nThis number would be (sum of the size of each term bucket aggregation in this array)\nand should be kept below 10,000. Any request breaching this limit would fail.\n",
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": {
        "$ref": "#/$defs/AggregatesFieldConfig"
      }
    }
  },
  "$defs": {
    "AggregatesField": {
      "type": "object",
      "description": "Field to be used for aggregation. Depending on the type of aggregation, this can have additional properties to control different aspects.\n",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "The name of the field to be used for the aggregation. This is typically a field in the document that you want to either filter on (bucket aggregation) or get the stats for.\nFor example, if you want to filter documents based on their `category`, you would specify the `category` field here.\nSimilarly if you want to get stats like min, max, avg for a numerical field like `price`, you would specify the `price` field here.\nThe field should have been indexed in the search index as a filter and should be suitable for aggregation.\nIf the field is not indexed, the underlying implementation will usually send an empty result. However in some cases\nit can also result in an error, for instance if the field type is not suitable for the requested aggregation (string field for number stats aggregation).\n"
        }
      }
    },
    "AggregatesFieldConfig": {
      "type": "object",
      "required": [
        "type",
        "id",
        "field"
      ],
      "properties": {
        "field": {
          "$ref": "#/$defs/AggregatesField"
        },
        "type": {
          "$ref": "#/$defs/AggregatesType"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "A unique identifier for this aggregate configuration. This id will be returned in the response to identify the aggregate results.\nIt is recommended to use a meaningful name that reflects the purpose of the aggregate.\nFor example, `categoryBucket`, `priceStats` etc.\n"
        },
        "filter": {
          "$ref": "#/$defs/ContentAIQueryFilter",
          "type": "object",
          "description": "Pre-filters for the aggregation. This is to limit the search space prior to calculating the aggregates for this particular field.\nAggregation would be performed only on the docs that match the filter criteria.\nThis can be useful for dynamic aggregation, where you want to calculate aggregate based on some selected filters on fields other than this one.\nFor example, consider you have 3 indexed fields - `title`, `modifiedDate` and `category`. Filters have been applied on `category = news` and `modifiedDate > 2023-01-01`.\nNow, if you want to calculate the aggregation for the `title` field, you would specify the `filter` with the filters on `category` and `modifiedDate`\nso that the aggregations for the `title` field accommodate the filters applied for other fields.\n- Without filter: aggregations always mirror the current query result set (aggregation done on the main search results).  \n- With filter: buckets can be scoped to a different context (dynamic aggregation), meaning each aggregation can compute results independently of the global search filters.\nTo limit the documents on which all aggregations in a search run, use a top-level `query filter`. This is faster than a single filter aggregation.\n"
        },
        "lexicalSpaceSelection": {
          "$ref": "#/$defs/SpaceSelection",
          "type": "object",
          "description": "Lexical Space selection for calculating the aggregates. This will be used for the filters\napplied in context of the aggregates.\nUse the lexical space that has the required fields mapped in relevant filters.\nIf not provided, default lexical space will be used.\n"
        }
      }
    },
    "AggregatesType": {
      "type": "string",
      "minLength": 1,
      "description": "The type of aggregation required on the specified field.\n- `termBuckets`: Term bucketing is used to get the unique values for a field and their respective counts.\n                 This is applicable for both string fields and non string (boolean, number and date) fields.\n- `numberStats`: Number stats aggregation is used to get statistical information field,\n                 such as count, min, max, average, and sum. This is applicable only for non string fields like number,\n                 boolean and date fields.\n                 Requesting this aggregation on a string field will result in an error.\n",
      "enum": [
        "termBuckets",
        "numberStats"
      ]
    },
    "ContentAIQuery": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1,
          "enum": [
            "vector",
            "fulltext",
            "filter",
            "composite"
          ],
          "description": "Type of the query that determines how the search will be performed:\n- vector: Semantic search using vector embeddings.\n- fulltext: Traditional fulltext search.\n- filter: Search for exact matches using filters.\n- composite: Combination of multiple query types. This can be used as a combination of vector and fulltext queries to perform a hybrid search.\n"
        }
      }
    },
    "ContentAIQueryFilter": {
      "type": "object",
      "required": [
        "filterComponent"
      ],
      "properties": {
        "filterComponent": {
          "$ref": "#/$defs/FilterComponent",
          "type": "object",
          "description": "Filter component to define filters on string, number, boolean, or date fields.\nThe filter can be a single filter or a group of filters combined with AND/OR/NOT operators.\n"
        }
      }
    },
    "ContentAIQueryOptions": {
      "type": "object",
      "properties": {
        "pagination": {
          "$ref": "#/$defs/PaginationOptions",
          "type": "object",
          "description": "Options to control paginated search results."
        },
        "sort": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/QuerySort"
          },
          "description": "List of sort objects for the query.\nDefault sort is on DESC score of a document, with the document id (ASC) as a tiebreaker.\nDocument id (ASC) is always added as a tiebreaker for any sorts specified.\n"
        },
        "eTag": {
          "type": "boolean",
          "description": "When set to true, each document in the search results will include an `eTag` field.\nThis `eTag` represents the current entity tag for that specific document, allowing clients to use it for optimistic\nconcurrency control during document updates. This is useful if documents returned as part of the search request are\ngoing to be used to form update requests.\nIf not specified or set to false, the `eTag` field will not be included in the search results.\n",
          "default": false
        },
        "resultFields": {
          "type": "object",
          "description": "This can be used to control the fields returned in the result documents.\nIf the `includes` property is specified, only source fields that match one of its patterns are returned. \nYou can exclude fields from this subset using the `excludes` property.\nSo, first the `includes` is evaluated and then `excludes` is applied on the subset of fields selected by `includes`.\nIf the `includes` property is not specified, the entire document source is returned, excluding any fields that match a pattern in the `excludes` property.\nIf both `includes` and `excludes` have the same field, the field is excluded.\nEach value in the includes or excludes field can be a full field name or a wildcard pattern, e.g., `field*` (matching `field1`, `fieldXYZ`, etc.).\n",
          "properties": {
            "includes": {
              "type": "array",
              "minItems": 1,
              "maxItems": 20,
              "items": {
                "type": "string"
              }
            },
            "excludes": {
              "type": "array",
              "minItems": 1,
              "maxItems": 20,
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "ContentSourceSearchConfig": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "description": "Name of the content source.",
          "type": "string"
        },
        "type": {
          "allOf": [
            {
              "$ref": "#/$defs/ContentSourceType"
            }
          ],
          "description": "Type of the content source. Defaults to `ACQUISITION` if not specified.",
          "default": "ACQUISITION"
        }
      }
    },
    "ContentSourceType": {
      "type": "string",
      "minLength": 1,
      "description": "The type of the content source.\n* AEM_AUTHOR: Content sourced from an AEM Author instance (pre-publication, draft content).\n* AEM_PUBLISH: Content sourced from an AEM Publish instance (live, published content).\n* ACQUISITION: Content acquired using the Content AI acquisition service, ingested based on\n               acquisition configs defined for the tenant.\n* CUSTOM: Content pushed by the client through direct index ingestion.\n",
      "enum": [
        "AEM_AUTHOR",
        "AEM_PUBLISH",
        "ACQUISITION",
        "CUSTOM"
      ]
    },
    "FilterComponent": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1,
          "description": "Type of the filter component"
        }
      }
    },
    "PaginationOptions": {
      "type": "object",
      "properties": {
        "limit": {
          "type": "integer",
          "format": "int32",
          "description": "The maximum number of items to return",
          "default": 10,
          "maximum": 50
        },
        "cursor": {
          "type": "string",
          "minLength": 1,
          "description": "A cursor is an opaque string that can be used in API calls which support paginating the response.\nA non-existent cursor signifies that the returned list does not have more elements.\n"
        }
      }
    },
    "QuerySort": {
      "type": "object",
      "required": [
        "orderBy"
      ],
      "properties": {
        "orderBy": {
          "description": "The value of an `orderBy` parameter contains an expression used to sort the search results.\n\nThe expression may include the suffix `asc` for ascending or `desc` for descending, separated from the property\nname by one or more spaces. If `asc` or `desc` is not specified, the service will order by the specified\nproperty in ascending order.\n",
          "type": "string",
          "minLength": 1
        },
        "lexicalSpaceSelection": {
          "$ref": "#/$defs/SpaceSelection",
          "type": "object",
          "description": "Lexical Space selection for the query."
        }
      }
    },
    "SpaceSelection": {
      "type": "object",
      "properties": {
        "space": {
          "type": "string",
          "description": "Name of the space to be used across all the indexes being queried upon.\nThe value should be from one of the spaces defined in the IndexConfig.\nIf not provided, default space will be used."
        }
      }
    }
  }
}