{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amazon-kendra/json-schema/amazon-kendra-query-request-schema.json",
  "title": "QueryRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amazon-kendra-operations-api-openapi.yml#/components/schemas/QueryRequest",
  "type": "object",
  "properties": {
    "IndexId": {
      "type": "string",
      "description": "The identifier of the index for the search."
    },
    "QueryText": {
      "type": "string",
      "description": "The input query text for the search. Amazon Kendra truncates queries at 30 token words, which excludes punctuation and stop words. Truncation still applies if you use Boolean or more advanced, complex queries. For example, Timeoff AND October AND Category:HR is counted as 3 tokens: timeoff, october, hr. For more information, see Searching with advanced query syntax in the Amazon Kendra Developer Guide."
    },
    "AttributeFilter": {
      "$ref": "#/$defs/AttributeFilter"
    },
    "Facets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Facet"
      },
      "description": "An array of documents fields/attributes for faceted search. Amazon Kendra returns a count for each field key specified. This helps your users narrow their search."
    },
    "RequestedDocumentAttributes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "An array of document fields/attributes to include in the response. You can limit the response to include certain document fields. By default, all document attributes are included in the response."
    },
    "QueryResultTypeFilter": {
      "type": "string",
      "enum": [
        "DOCUMENT",
        "QUESTION_ANSWER",
        "ANSWER"
      ],
      "description": "Sets the type of query result or response. Only results for the specified type are returned."
    },
    "DocumentRelevanceOverrideConfigurations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentRelevanceConfiguration"
      },
      "description": "Overrides relevance tuning configurations of fields/attributes set at the index level. If you use this API to override the relevance tuning configured at the index level, but there is no relevance tuning configured at the index level, then Amazon Kendra does not apply any relevance tuning. If there is relevance tuning configured for fields at the index level, and you use this API to override only some of these fields, then for the fields you did not override, the importance is set to 1."
    },
    "PageNumber": {
      "type": "integer",
      "description": "Query results are returned in pages the size of the PageSize parameter. By default, Amazon Kendra returns the first page of results. Use this parameter to get result pages after the first one."
    },
    "PageSize": {
      "type": "integer",
      "description": "Sets the number of results that are returned in each page of results. The default page size is 10. The maximum number of results returned is 100. If you ask for more than 100 results, only 100 are returned."
    },
    "SortingConfiguration": {
      "$ref": "#/$defs/SortingConfiguration"
    },
    "SortingConfigurations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SortingConfiguration"
      },
      "description": "Provides configuration information to determine how the results of a query are sorted. You can set upto 3 fields that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. The sort field quota can be increased. If you don't provide a sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result. In the case of ties in sorting the results, the results are sorted by relevance."
    },
    "UserContext": {
      "$ref": "#/$defs/UserContext"
    },
    "VisitorId": {
      "type": "string",
      "description": "Provides an identifier for a specific user. The VisitorId should be a unique identifier, such as a GUID. Don't use personally identifiable information, such as the user's email address, as the VisitorId."
    },
    "SpellCorrectionConfiguration": {
      "$ref": "#/$defs/SpellCorrectionConfiguration"
    },
    "CollapseConfiguration": {
      "$ref": "#/$defs/CollapseConfiguration"
    }
  },
  "required": [
    "IndexId"
  ],
  "$defs": {
    "AttributeFilter": {
      "type": "object",
      "properties": {
        "AndAllFilters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AttributeFilter"
          },
          "description": "Performs a logical AND operation on all filters that you specify."
        },
        "OrAllFilters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AttributeFilter"
          },
          "description": "Performs a logical OR operation on all filters that you specify."
        },
        "NotFilter": {
          "$ref": "#/$defs/AttributeFilter"
        },
        "EqualsTo": {
          "$ref": "#/$defs/DocumentAttribute"
        },
        "ContainsAll": {
          "$ref": "#/$defs/DocumentAttribute"
        },
        "ContainsAny": {
          "$ref": "#/$defs/DocumentAttribute"
        },
        "GreaterThan": {
          "$ref": "#/$defs/DocumentAttribute"
        },
        "GreaterThanOrEquals": {
          "$ref": "#/$defs/DocumentAttribute"
        },
        "LessThan": {
          "$ref": "#/$defs/DocumentAttribute"
        },
        "LessThanOrEquals": {
          "$ref": "#/$defs/DocumentAttribute"
        }
      }
    },
    "CollapseConfiguration": {
      "type": "object",
      "properties": {
        "DocumentAttributeKey": {
          "type": "string",
          "description": "The document attribute used to group search results. You can use any attribute that has the Sortable flag set to true. You can also sort by any of the following built-in attributes:\"_category\",\"_created_at\", \"_last_updated_at\", \"_version\", \"_view_count\"."
        },
        "SortingConfigurations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SortingConfiguration"
          },
          "description": "A prioritized list of document attributes/fields that determine the primary document among those in a collapsed group."
        },
        "MissingAttributeKeyStrategy": {
          "type": "string",
          "enum": [
            "IGNORE",
            "COLLAPSE",
            "EXPAND"
          ],
          "description": "Specifies the behavior for documents without a value for the collapse attribute. Amazon Kendra offers three customization options: Choose to COLLAPSE all documents with null or missing values in one group. This is the default configuration. Choose to IGNORE documents with null or missing values. Ignored documents will not appear in query results. Choose to EXPAND each document with a null or missing value into a group of its own."
        },
        "Expand": {
          "type": "boolean",
          "description": "Specifies whether to expand the collapsed results."
        },
        "ExpandConfiguration": {
          "$ref": "#/$defs/ExpandConfiguration"
        }
      },
      "required": [
        "DocumentAttributeKey"
      ]
    },
    "DataSourceGroup": {
      "type": "object",
      "properties": {
        "GroupId": {
          "type": "string",
          "description": "The identifier of the group you want to add to your list of groups. This is for filtering search results based on the groups' access to documents."
        },
        "DataSourceId": {
          "type": "string",
          "description": "The identifier of the data source group you want to add to your list of data source groups. This is for filtering search results based on the groups' access to documents in that data source."
        }
      },
      "required": [
        "GroupId",
        "DataSourceId"
      ]
    },
    "DocumentAttribute": {
      "type": "object",
      "properties": {
        "Key": {
          "type": "string",
          "description": "The identifier for the attribute."
        },
        "Value": {
          "$ref": "#/$defs/DocumentAttributeValue"
        }
      },
      "required": [
        "Key",
        "Value"
      ]
    },
    "DocumentAttributeValue": {
      "type": "object",
      "properties": {
        "StringValue": {
          "type": "string",
          "description": "A string, such as \"department\"."
        },
        "StringListValue": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "A list of strings. The default maximum length or number of strings is 10."
        },
        "LongValue": {
          "type": "integer",
          "description": "A long integer value."
        },
        "DateValue": {
          "type": "string",
          "format": "date-time",
          "description": "A date expressed as an ISO 8601 string. It is important for the time zone to be included in the ISO 8601 date-time format. For example, 2012-03-25T12:30:10+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time."
        }
      }
    },
    "DocumentRelevanceConfiguration": {
      "type": "object",
      "properties": {
        "Name": {
          "type": "string",
          "description": "The name of the index field."
        },
        "Relevance": {
          "$ref": "#/$defs/Relevance"
        }
      },
      "required": [
        "Name",
        "Relevance"
      ]
    },
    "ExpandConfiguration": {
      "type": "object",
      "properties": {
        "MaxResultItemsToExpand": {
          "type": "integer",
          "description": "The number of collapsed search result groups to expand. If you set this value to 10, for example, only the first 10 out of 100 result groups will have expand functionality."
        },
        "MaxExpandedResultsPerItem": {
          "type": "integer",
          "description": "The number of expanded results to show per collapsed primary document. For instance, if you set this value to 3, then at most 3 results per collapsed group will be displayed."
        }
      }
    },
    "Facet": {
      "type": "object",
      "properties": {
        "DocumentAttributeKey": {
          "type": "string",
          "description": "The unique key for the document attribute."
        },
        "Facets": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Facet"
          },
          "description": "An array of document attributes that are nested facets within a facet. For example, the document attribute or facet \"Department\" includes a value called \"Engineering\". In addition, the document attribute or facet \"SubDepartment\" includes the values \"Frontend\" and \"Backend\" for documents assigned to \"Engineering\". You can display nested facets in the search results so that documents can be searched not only by department but also by a sub department within a department. This helps your users further narrow their search. You can only have one nested facet within a facet. If you want to increase "
        },
        "MaxResults": {
          "type": "integer",
          "description": "Maximum number of facet values per facet. The default is 10. You can use this to limit the number of facet values to less than 10. If you want to increase the default, contact Support."
        }
      }
    },
    "Relevance": {
      "type": "object",
      "properties": {
        "Freshness": {
          "type": "boolean",
          "description": "Indicates that this field determines how \"fresh\" a document is. For example, if document 1 was created on November 5, and document 2 was created on October 31, document 1 is \"fresher\" than document 2. Only applies to DATE fields."
        },
        "Importance": {
          "type": "integer",
          "description": "The relative importance of the field in the search. Larger numbers provide more of a boost than smaller numbers."
        },
        "Duration": {
          "type": "string",
          "description": "Specifies the time period that the boost applies to. For example, to make the boost apply to documents with the field value within the last month, you would use \"2628000s\". Once the field value is beyond the specified range, the effect of the boost drops off. The higher the importance, the faster the effect drops off. If you don't specify a value, the default is 3 months. The value of the field is a numeric string followed by the character \"s\", for example \"86400s\" for one day, or \"604800s\" for one week. Only applies to DATE fields."
        },
        "RankOrder": {
          "type": "string",
          "enum": [
            "ASCENDING",
            "DESCENDING"
          ],
          "description": "Determines how values should be interpreted. When the RankOrder field is ASCENDING, higher numbers are better. For example, a document with a rating score of 10 is higher ranking than a document with a rating score of 1. When the RankOrder field is DESCENDING, lower numbers are better. For example, in a task tracking application, a priority 1 task is more important than a priority 5 task. Only applies to LONG fields."
        },
        "ValueImportanceMap": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          },
          "description": "A list of values that should be given a different boost when they appear in the result list. For example, if you are boosting a field called \"department\", query terms that match the department field are boosted in the result. However, you can add entries from the department field to boost documents with those values higher. For example, you can add entries to the map with names of departments. If you add \"HR\",5 and \"Legal\",3 those departments are given special attention when they appear in the metadata of a document. When those terms appear they are given the specified importance instead of th"
        }
      }
    },
    "SortingConfiguration": {
      "type": "object",
      "properties": {
        "DocumentAttributeKey": {
          "type": "string",
          "description": "The name of the document attribute used to sort the response. You can use any field that has the Sortable flag set to true. You can also sort by any of the following built-in attributes: _category _created_at _last_updated_at _version _view_count"
        },
        "SortOrder": {
          "type": "string",
          "enum": [
            "DESC",
            "ASC"
          ],
          "description": "The order that the results should be returned in. In case of ties, the relevance assigned to the result by Amazon Kendra is used as the tie-breaker."
        }
      },
      "required": [
        "DocumentAttributeKey",
        "SortOrder"
      ]
    },
    "SpellCorrectionConfiguration": {
      "type": "object",
      "properties": {
        "IncludeQuerySpellCheckSuggestions": {
          "type": "boolean",
          "description": "TRUE to suggest spell corrections for queries."
        }
      },
      "required": [
        "IncludeQuerySpellCheckSuggestions"
      ]
    },
    "UserContext": {
      "type": "object",
      "properties": {
        "Token": {
          "type": "string",
          "description": "The user context token for filtering search results for a user. It must be a JWT or a JSON token."
        },
        "UserId": {
          "type": "string",
          "description": "The identifier of the user you want to filter search results based on their access to documents."
        },
        "Groups": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The list of groups you want to filter search results based on the groups' access to documents."
        },
        "DataSourceGroups": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DataSourceGroup"
          },
          "description": "The list of data source groups you want to filter search results based on groups' access to documents in that data source."
        }
      }
    }
  }
}