2020/12/10 - AWSKendraFrontendService - 5 new 1 updated api methods
Changes Amazon Kendra now supports adding synonyms to an index through the new Thesaurus resource.
Lists the Amazon Kendra thesauri associated with an index.
See also: AWS API Documentation
Request Syntax
client.list_thesauri( IndexId='string', NextToken='string', MaxResults=123 )
string
[REQUIRED]
The identifier of the index associated with the thesaurus to list.
string
If the previous response was incomplete (because there is more data to retrieve), Amazon Kendra returns a pagination token in the response. You can use this pagination token to retrieve the next set of thesauri (ThesaurusSummaryItems ).
integer
The maximum number of thesauri to return.
dict
Response Syntax
{ 'NextToken': 'string', 'ThesaurusSummaryItems': [ { 'Id': 'string', 'Name': 'string', 'Status': 'CREATING'|'ACTIVE'|'DELETING'|'UPDATING'|'ACTIVE_BUT_UPDATE_FAILED'|'FAILED', 'CreatedAt': datetime(2015, 1, 1), 'UpdatedAt': datetime(2015, 1, 1) }, ] }
Response Structure
(dict) --
NextToken (string) --
If the response is truncated, Amazon Kendra returns this token that you can use in the subsequent request to retrieve the next set of thesauri.
ThesaurusSummaryItems (list) --
An array of summary information for one or more thesauruses.
(dict) --
An array of summary information for one or more thesauruses.
Id (string) --
The identifier of the thesaurus.
Name (string) --
The name of the thesaurus.
Status (string) --
The status of the thesaurus.
CreatedAt (datetime) --
The Unix datetime that the thesaurus was created.
UpdatedAt (datetime) --
The Unix datetime that the thesaurus was last updated.
Describes an existing Amazon Kendra thesaurus.
See also: AWS API Documentation
Request Syntax
client.describe_thesaurus( Id='string', IndexId='string' )
string
[REQUIRED]
The identifier of the thesaurus to describe.
string
[REQUIRED]
The identifier of the index associated with the thesaurus to describe.
dict
Response Syntax
{ 'Id': 'string', 'IndexId': 'string', 'Name': 'string', 'Description': 'string', 'Status': 'CREATING'|'ACTIVE'|'DELETING'|'UPDATING'|'ACTIVE_BUT_UPDATE_FAILED'|'FAILED', 'ErrorMessage': 'string', 'CreatedAt': datetime(2015, 1, 1), 'UpdatedAt': datetime(2015, 1, 1), 'RoleArn': 'string', 'SourceS3Path': { 'Bucket': 'string', 'Key': 'string' }, 'FileSizeBytes': 123, 'TermCount': 123, 'SynonymRuleCount': 123 }
Response Structure
(dict) --
Id (string) --
The identifier of the thesaurus.
IndexId (string) --
The identifier of the index associated with the thesaurus to describe.
Name (string) --
The thesaurus name.
Description (string) --
The thesaurus description.
Status (string) --
The current status of the thesaurus. When the value is ACTIVE , queries are able to use the thesaurus. If the Status field value is FAILED , the ErrorMessage field provides more information.
If the status is ACTIVE_BUT_UPDATE_FAILED , it means that Amazon Kendra could not ingest the new thesaurus file. The old thesaurus file is still active.
ErrorMessage (string) --
When the Status field value is FAILED , the ErrorMessage field provides more information.
CreatedAt (datetime) --
The Unix datetime that the thesaurus was created.
UpdatedAt (datetime) --
The Unix datetime that the thesaurus was last updated.
RoleArn (string) --
An AWS Identity and Access Management (IAM) role that gives Amazon Kendra permissions to access thesaurus file specified in SourceS3Path .
SourceS3Path (dict) --
Information required to find a specific file in an Amazon S3 bucket.
Bucket (string) --
The name of the S3 bucket that contains the file.
Key (string) --
The name of the file.
FileSizeBytes (integer) --
The size of the thesaurus file in bytes.
TermCount (integer) --
The number of unique terms in the thesaurus file. For example, the synonyms a,b,c and a=>d , the term count would be 4.
SynonymRuleCount (integer) --
The number of synonym rules in the thesaurus file.
Creates a thesaurus for an index. The thesaurus contains a list of synonyms in Solr format.
See also: AWS API Documentation
Request Syntax
client.create_thesaurus( IndexId='string', Name='string', Description='string', RoleArn='string', Tags=[ { 'Key': 'string', 'Value': 'string' }, ], SourceS3Path={ 'Bucket': 'string', 'Key': 'string' }, ClientToken='string' )
string
[REQUIRED]
The unique identifier of the index for the new thesaurus.
string
[REQUIRED]
The name for the new thesaurus.
string
The description for the new thesaurus.
string
[REQUIRED]
An AWS Identity and Access Management (IAM) role that gives Amazon Kendra permissions to access thesaurus file specified in SourceS3Path .
list
A list of key-value pairs that identify the thesaurus. You can use the tags to identify and organize your resources and to control access to resources.
(dict) --
A list of key/value pairs that identify an index, FAQ, or data source. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.
Key (string) -- [REQUIRED]
The key for the tag. Keys are not case sensitive and must be unique for the index, FAQ, or data source.
Value (string) -- [REQUIRED]
The value associated with the tag. The value may be an empty string but it can't be null.
dict
[REQUIRED]
The thesaurus file Amazon S3 source path.
Bucket (string) -- [REQUIRED]
The name of the S3 bucket that contains the file.
Key (string) -- [REQUIRED]
The name of the file.
string
A token that you provide to identify the request to create a thesaurus. Multiple calls to the CreateThesaurus operation with the same client token will create only one index.
This field is autopopulated if not provided.
dict
Response Syntax
{ 'Id': 'string' }
Response Structure
(dict) --
Id (string) --
The unique identifier of the thesaurus.
Updates a thesaurus file associated with an index.
See also: AWS API Documentation
Request Syntax
client.update_thesaurus( Id='string', Name='string', IndexId='string', Description='string', RoleArn='string', SourceS3Path={ 'Bucket': 'string', 'Key': 'string' } )
string
[REQUIRED]
The identifier of the thesaurus to update.
string
The updated name of the thesaurus.
string
[REQUIRED]
The identifier of the index associated with the thesaurus to update.
string
The updated description of the thesaurus.
string
The updated role ARN of the thesaurus.
dict
Information required to find a specific file in an Amazon S3 bucket.
Bucket (string) -- [REQUIRED]
The name of the S3 bucket that contains the file.
Key (string) -- [REQUIRED]
The name of the file.
None
Deletes an existing Amazon Kendra thesaurus.
See also: AWS API Documentation
Request Syntax
client.delete_thesaurus( Id='string', IndexId='string' )
string
[REQUIRED]
The identifier of the thesaurus to delete.
string
[REQUIRED]
The identifier of the index associated with the thesaurus to delete.
None
{'ResultItems': {'AdditionalAttributes': {'Value': {'TextWithHighlightsValue': {'Highlights': {'Type': 'STANDARD ' '| ' 'THESAURUS_SYNONYM'}}}}, 'DocumentExcerpt': {'Highlights': {'Type': 'STANDARD | ' 'THESAURUS_SYNONYM'}}, 'DocumentTitle': {'Highlights': {'Type': 'STANDARD | ' 'THESAURUS_SYNONYM'}}}}
Searches an active index. Use this API to search your documents using query. The Query operation enables to do faceted search and to filter results based on document attributes.
It also enables you to provide user context that Amazon Kendra uses to enforce document access control in the search results.
Amazon Kendra searches your index for text content and question and answer (FAQ) content. By default the response contains three types of results.
Relevant passages
Matching FAQs
Relevant documents
You can specify that the query return only one type of result using the QueryResultTypeConfig parameter.
Each query returns the 100 most relevant results.
See also: AWS API Documentation
Request Syntax
client.query( IndexId='string', QueryText='string', AttributeFilter={ 'AndAllFilters': [ {'... recursive ...'}, ], 'OrAllFilters': [ {'... recursive ...'}, ], 'NotFilter': {'... recursive ...'}, 'EqualsTo': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, 'ContainsAll': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, 'ContainsAny': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, 'GreaterThan': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, 'GreaterThanOrEquals': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, 'LessThan': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, 'LessThanOrEquals': { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } } }, Facets=[ { 'DocumentAttributeKey': 'string' }, ], RequestedDocumentAttributes=[ 'string', ], QueryResultTypeFilter='DOCUMENT'|'QUESTION_ANSWER'|'ANSWER', PageNumber=123, PageSize=123, SortingConfiguration={ 'DocumentAttributeKey': 'string', 'SortOrder': 'DESC'|'ASC' }, UserContext={ 'Token': 'string' }, VisitorId='string' )
string
[REQUIRED]
The unique identifier of the index to search. The identifier is returned in the response from the operation.
string
[REQUIRED]
The text to search for.
dict
Enables filtered searches based on document attributes. You can only provide one attribute filter; however, the AndAllFilters , NotFilter , and OrAllFilters parameters contain a list of other filters.
The AttributeFilter parameter enables you to create a set of filtering rules that a document must satisfy to be included in the query results.
AndAllFilters (list) --
Performs a logical AND operation on all supplied filters.
(dict) --
Provides filtering the query results based on document attributes.
When you use the AndAllFilters or OrAllFilters , filters you can use 2 layers under the first attribute filter. For example, you can use:
<AndAllFilters>
<OrAllFilters>
<EqualTo>
If you use more than 2 layers, you receive a ValidationException exception with the message "AttributeFilter cannot have a depth of more than 2."
OrAllFilters (list) --
Performs a logical OR operation on all supplied filters.
(dict) --
Provides filtering the query results based on document attributes.
When you use the AndAllFilters or OrAllFilters , filters you can use 2 layers under the first attribute filter. For example, you can use:
<AndAllFilters>
<OrAllFilters>
<EqualTo>
If you use more than 2 layers, you receive a ValidationException exception with the message "AttributeFilter cannot have a depth of more than 2."
NotFilter (dict) --
Performs a logical NOT operation on all supplied filters.
EqualsTo (dict) --
Performs an equals operation on two document attributes.
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
ContainsAll (dict) --
Returns true when a document contains all of the specified document attributes. This filter is only applicable to StringListValue metadata.
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
ContainsAny (dict) --
Returns true when a document contains any of the specified document attributes. This filter is only applicable to StringListValue metadata.
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
GreaterThan (dict) --
Performs a greater than operation on two document attributes. Use with a document attribute of type Integer or Long .
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
GreaterThanOrEquals (dict) --
Performs a greater or equals than operation on two document attributes. Use with a document attribute of type Integer or Long .
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
LessThan (dict) --
Performs a less than operation on two document attributes. Use with a document attribute of type Integer or Long .
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
LessThanOrEquals (dict) --
Performs a less than or equals operation on two document attributes. Use with a document attribute of type Integer or Long .
Key (string) -- [REQUIRED]
The identifier for the attribute.
Value (dict) -- [REQUIRED]
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
list
An array of documents attributes. Amazon Kendra returns a count for each attribute key specified. You can use this information to help narrow the search for your user.
(dict) --
Information about a document attribute
DocumentAttributeKey (string) --
The unique key for the document attribute.
list
An array of document attributes to include in the response. No other document attributes are included in the response. By default all document attributes are included in the response.
(string) --
string
Sets the type of query. Only results for the specified query type are returned.
integer
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.
integer
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.
dict
Provides information that determines how the results of the query are sorted. You can set the field that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. In the case of ties in sorting the results, the results are sorted by relevance.
If you don't provide sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result.
DocumentAttributeKey (string) -- [REQUIRED]
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 (string) -- [REQUIRED]
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.
dict
The user context token.
Token (string) --
The user context token. It must be a JWT or a JSON token.
string
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 .
dict
Response Syntax
{ 'QueryId': 'string', 'ResultItems': [ { 'Id': 'string', 'Type': 'DOCUMENT'|'QUESTION_ANSWER'|'ANSWER', 'AdditionalAttributes': [ { 'Key': 'string', 'ValueType': 'TEXT_WITH_HIGHLIGHTS_VALUE', 'Value': { 'TextWithHighlightsValue': { 'Text': 'string', 'Highlights': [ { 'BeginOffset': 123, 'EndOffset': 123, 'TopAnswer': True|False, 'Type': 'STANDARD'|'THESAURUS_SYNONYM' }, ] } } }, ], 'DocumentId': 'string', 'DocumentTitle': { 'Text': 'string', 'Highlights': [ { 'BeginOffset': 123, 'EndOffset': 123, 'TopAnswer': True|False, 'Type': 'STANDARD'|'THESAURUS_SYNONYM' }, ] }, 'DocumentExcerpt': { 'Text': 'string', 'Highlights': [ { 'BeginOffset': 123, 'EndOffset': 123, 'TopAnswer': True|False, 'Type': 'STANDARD'|'THESAURUS_SYNONYM' }, ] }, 'DocumentURI': 'string', 'DocumentAttributes': [ { 'Key': 'string', 'Value': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) } }, ], 'ScoreAttributes': { 'ScoreConfidence': 'VERY_HIGH'|'HIGH'|'MEDIUM'|'LOW' }, 'FeedbackToken': 'string' }, ], 'FacetResults': [ { 'DocumentAttributeKey': 'string', 'DocumentAttributeValueType': 'STRING_VALUE'|'STRING_LIST_VALUE'|'LONG_VALUE'|'DATE_VALUE', 'DocumentAttributeValueCountPairs': [ { 'DocumentAttributeValue': { 'StringValue': 'string', 'StringListValue': [ 'string', ], 'LongValue': 123, 'DateValue': datetime(2015, 1, 1) }, 'Count': 123 }, ] }, ], 'TotalNumberOfResults': 123 }
Response Structure
(dict) --
QueryId (string) --
The unique identifier for the search. You use QueryId to identify the search when using the feedback API.
ResultItems (list) --
The results of the search.
(dict) --
A single query result.
A query result contains information about a document returned by the query. This includes the original location of the document, a list of attributes assigned to the document, and relevant text from the document that satisfies the query.
Id (string) --
The unique identifier for the query result.
Type (string) --
The type of document.
AdditionalAttributes (list) --
One or more additional attributes associated with the query result.
(dict) --
An attribute returned from an index query.
Key (string) --
The key that identifies the attribute.
ValueType (string) --
The data type of the Value property.
Value (dict) --
An object that contains the attribute value.
TextWithHighlightsValue (dict) --
The text associated with the attribute and information about the highlight to apply to the text.
Text (string) --
The text to display to the user.
Highlights (list) --
The beginning and end of the text that should be highlighted.
(dict) --
Provides information that you can use to highlight a search result so that your users can quickly identify terms in the response.
BeginOffset (integer) --
The zero-based location in the response string where the highlight starts.
EndOffset (integer) --
The zero-based location in the response string where the highlight ends.
TopAnswer (boolean) --
Indicates whether the response is the best response. True if this is the best response; otherwise, false.
Type (string) --
The highlight type.
DocumentId (string) --
The unique identifier for the document.
DocumentTitle (dict) --
The title of the document. Contains the text of the title and information for highlighting the relevant terms in the title.
Text (string) --
The text to display to the user.
Highlights (list) --
The beginning and end of the text that should be highlighted.
(dict) --
Provides information that you can use to highlight a search result so that your users can quickly identify terms in the response.
BeginOffset (integer) --
The zero-based location in the response string where the highlight starts.
EndOffset (integer) --
The zero-based location in the response string where the highlight ends.
TopAnswer (boolean) --
Indicates whether the response is the best response. True if this is the best response; otherwise, false.
Type (string) --
The highlight type.
DocumentExcerpt (dict) --
An extract of the text in the document. Contains information about highlighting the relevant terms in the excerpt.
Text (string) --
The text to display to the user.
Highlights (list) --
The beginning and end of the text that should be highlighted.
(dict) --
Provides information that you can use to highlight a search result so that your users can quickly identify terms in the response.
BeginOffset (integer) --
The zero-based location in the response string where the highlight starts.
EndOffset (integer) --
The zero-based location in the response string where the highlight ends.
TopAnswer (boolean) --
Indicates whether the response is the best response. True if this is the best response; otherwise, false.
Type (string) --
The highlight type.
DocumentURI (string) --
The URI of the original location of the document.
DocumentAttributes (list) --
An array of document attributes for the document that the query result maps to. For example, the document author (Author) or the source URI (SourceUri) of the document.
(dict) --
A custom attribute value assigned to a document.
Key (string) --
The identifier for the attribute.
Value (dict) --
The value of the attribute.
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
ScoreAttributes (dict) --
Indicates the confidence that Amazon Kendra has that a result matches the query that you provided. Each result is placed into a bin that indicates the confidence, VERY_HIGH , HIGH , MEDIUM and LOW . You can use the score to determine if a response meets the confidence needed for your application.
The field is only set to LOW when the Type field is set to DOCUMENT and Amazon Kendra is not confident that the result matches the query.
ScoreConfidence (string) --
A relative ranking for how well the response matches the query.
FeedbackToken (string) --
A token that identifies a particular result from a particular query. Use this token to provide click-through feedback for the result. For more information, see Submitting feedback .
FacetResults (list) --
Contains the facet results. A FacetResult contains the counts for each attribute key that was specified in the Facets input parameter.
(dict) --
The facet values for the documents in the response.
DocumentAttributeKey (string) --
The key for the facet values. This is the same as the DocumentAttributeKey provided in the query.
DocumentAttributeValueType (string) --
The data type of the facet value. This is the same as the type defined for the index field when it was created.
DocumentAttributeValueCountPairs (list) --
An array of key/value pairs, where the key is the value of the attribute and the count is the number of documents that share the key value.
(dict) --
Provides the count of documents that match a particular attribute when doing a faceted search.
DocumentAttributeValue (dict) --
The value of the attribute. For example, "HR."
StringValue (string) --
A string, such as "department".
StringListValue (list) --
A list of strings.
(string) --
LongValue (integer) --
A long integer value.
DateValue (datetime) --
A date expressed as an ISO 8601 string.
Count (integer) --
The number of documents in the response that have the attribute value for the key.
TotalNumberOfResults (integer) --
The total number of items found by the search; however, you can only retrieve up to 100 items. For example, if the search found 192 items, you can only retrieve the first 100 of the items.