AWSKendraFrontendService

2021/07/12 - AWSKendraFrontendService - 4 new2 updated api methods

Changes  Amazon Kendra now supports Principal Store

PutPrincipalMapping (new) Link ¶

Maps users to their groups. You can also map sub groups to groups. For example, the group "Company Intellectual Property Teams" includes sub groups "Research" and "Engineering". These sub groups include their own list of users or people who work in these teams. Only users who work in research and engineering, and therefore belong in the intellectual property group, can see top-secret company documents in their search results.

You map users to their groups when you want to filter search results for different users based on their group’s access to documents. For more information on filtering search results for different users, see Filtering on user context.

If more than five PUT actions for a group are currently processing, a validation exception is thrown.

See also: AWS API Documentation

Request Syntax

client.put_principal_mapping(
    IndexId='string',
    DataSourceId='string',
    GroupId='string',
    GroupMembers={
        'MemberGroups': [
            {
                'GroupId': 'string',
                'DataSourceId': 'string'
            },
        ],
        'MemberUsers': [
            {
                'UserId': 'string'
            },
        ],
        'S3PathforGroupMembers': {
            'Bucket': 'string',
            'Key': 'string'
        }
    },
    OrderingId=123,
    RoleArn='string'
)
type IndexId:

string

param IndexId:

[REQUIRED]

The identifier of the index you want to map users to their groups.

type DataSourceId:

string

param DataSourceId:

The identifier of the data source you want to map users to their groups.

This is useful if a group is tied to multiple data sources, but you only want the group to access documents of a certain data source. For example, the groups "Research", "Engineering", and "Sales and Marketing" are all tied to the company's documents stored in the data sources Confluence and Salesforce. However, "Sales and Marketing" team only needs access to customer-related documents stored in Salesforce.

type GroupId:

string

param GroupId:

[REQUIRED]

The identifier of the group you want to map its users to.

type GroupMembers:

dict

param GroupMembers:

[REQUIRED]

The list that contains your users or sub groups that belong the same group.

For example, the group "Company" includes the user "CEO" and the sub groups "Research", "Engineering", and "Sales and Marketing".

If you have more than 1000 users and/or sub groups for a single group, you need to provide the path to the S3 file that lists your users and sub groups for a group. Your sub groups can contain more than 1000 users, but the list of sub groups that belong to a group (and/or users) must be no more than 1000.

  • MemberGroups (list) --

    A list of sub groups that belong to a group. For example, the sub groups "Research", "Engineering", and "Sales and Marketing" all belong to the group "Company".

    • (dict) --

      The sub groups that belong to a group.

      • GroupId (string) -- [REQUIRED]

        The identifier of the sub group you want to map to a group.

      • DataSourceId (string) --

        The identifier of the data source for the sub group you want to map to a group.

  • MemberUsers (list) --

    A list of users that belong to a group. For example, a list of interns all belong to the "Interns" group.

    • (dict) --

      The users that belong to a group.

      • UserId (string) -- [REQUIRED]

        The identifier of the user you want to map to a group.

  • S3PathforGroupMembers (dict) --

    If you have more than 1000 users and/or sub groups for a single group, you need to provide the path to the S3 file that lists your users and sub groups for a group. Your sub groups can contain more than 1000 users, but the list of sub groups that belong to a group (and/or users) must be no more than 1000.

    • Bucket (string) -- [REQUIRED]

      The name of the S3 bucket that contains the file.

    • Key (string) -- [REQUIRED]

      The name of the file.

type OrderingId:

integer

param OrderingId:

The timestamp identifier you specify to ensure Amazon Kendra does not override the latest PUT action with previous actions. The highest number ID, which is the ordering ID, is the latest action you want to process and apply on top of other actions with lower number IDs. This prevents previous actions with lower number IDs from possibly overriding the latest action.

The ordering ID can be the UNIX time of the last update you made to a group members list. You would then provide this list when calling PutPrincipalMapping. This ensures your PUT action for that updated group with the latest members list doesn't get overwritten by earlier PUT actions for the same group which are yet to be processed.

The default ordering ID is the current UNIX time in milliseconds that the action was received by Amazon Kendra.

type RoleArn:

string

param RoleArn:

The Amazon Resource Name (ARN) of a role that has access to the S3 file that contains your list of users or sub groups that belong to a group.

For more information, see IAM roles for Amazon Kendra.

returns:

None

DeletePrincipalMapping (new) Link ¶

Deletes a group so that all users and sub groups that belong to the group can no longer access documents only available to that group.

For example, after deleting the group "Summer Interns", all interns who belonged to that group no longer see intern-only documents in their search results.

If you want to delete or replace users or sub groups of a group, you need to use the PutPrincipalMapping operation. For example, if a user in the group "Engineering" leaves the engineering team and another user takes their place, you provide an updated list of users or sub groups that belong to the "Engineering" group when calling PutPrincipalMapping. You can update your internal list of users or sub groups and input this list when calling PutPrincipalMapping.

See also: AWS API Documentation

Request Syntax

client.delete_principal_mapping(
    IndexId='string',
    DataSourceId='string',
    GroupId='string',
    OrderingId=123
)
type IndexId:

string

param IndexId:

[REQUIRED]

The identifier of the index you want to delete a group from.

type DataSourceId:

string

param DataSourceId:

The identifier of the data source you want to delete a group from.

This is useful if a group is tied to multiple data sources and you want to delete a group from accessing documents in a certain data source. For example, the groups "Research", "Engineering", and "Sales and Marketing" are all tied to the company's documents stored in the data sources Confluence and Salesforce. You want to delete "Research" and "Engineering" groups from Salesforce, so that these groups cannot access customer-related documents stored in Salesforce. Only "Sales and Marketing" should access documents in the Salesforce data source.

type GroupId:

string

param GroupId:

[REQUIRED]

The identifier of the group you want to delete.

type OrderingId:

integer

param OrderingId:

The timestamp identifier you specify to ensure Amazon Kendra does not override the latest DELETE action with previous actions. The highest number ID, which is the ordering ID, is the latest action you want to process and apply on top of other actions with lower number IDs. This prevents previous actions with lower number IDs from possibly overriding the latest action.

The ordering ID can be the UNIX time of the last update you made to a group members list. You would then provide this list when calling PutPrincipalMapping. This ensures your DELETE action for that updated group with the latest members list doesn't get overwritten by earlier DELETE actions for the same group which are yet to be processed.

The default ordering ID is the current UNIX time in milliseconds that the action was received by Amazon Kendra.

returns:

None

ListGroupsOlderThanOrderingId (new) Link ¶

Provides a list of groups that are mapped to users before a given ordering or timestamp identifier.

See also: AWS API Documentation

Request Syntax

client.list_groups_older_than_ordering_id(
    IndexId='string',
    DataSourceId='string',
    OrderingId=123,
    NextToken='string',
    MaxResults=123
)
type IndexId:

string

param IndexId:

[REQUIRED]

The identifier of the index for getting a list of groups mapped to users before a given ordering or timestamp identifier.

type DataSourceId:

string

param DataSourceId:

The identifier of the data source for getting a list of groups mapped to users before a given ordering timestamp identifier.

type OrderingId:

integer

param OrderingId:

[REQUIRED]

The timestamp identifier used for the latest PUT or DELETE action for mapping users to their groups.

type NextToken:

string

param NextToken:

The next items in the list of groups that go beyond the maximum.

type MaxResults:

integer

param MaxResults:

The maximum results shown for a list of groups that are mapped to users before a given ordering or timestamp identifier.

rtype:

dict

returns:

Response Syntax

{
    'GroupsSummaries': [
        {
            'GroupId': 'string',
            'OrderingId': 123
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • GroupsSummaries (list) --

      Summary information for list of groups that are mapped to users before a given ordering or timestamp identifier.

      • (dict) --

        Group summary information.

        • GroupId (string) --

          The identifier of the group you want group summary information on.

        • OrderingId (integer) --

          The timestamp identifier used for the latest PUT or DELETE action.

    • NextToken (string) --

      The next items in the list of groups that go beyond the maximum.

DescribePrincipalMapping (new) Link ¶

Describes the processing of PUT and DELETE actions for mapping users to their groups. This includes information on the status of actions currently processing or yet to be processed, when actions were last updated, when actions were received by Amazon Kendra, the latest action that should process and apply after other actions, and useful error messages if an action could not be processed.

See also: AWS API Documentation

Request Syntax

client.describe_principal_mapping(
    IndexId='string',
    DataSourceId='string',
    GroupId='string'
)
type IndexId:

string

param IndexId:

[REQUIRED]

The identifier of the index required to check the processing of PUT and DELETE actions for mapping users to their groups.

type DataSourceId:

string

param DataSourceId:

The identifier of the data source to check the processing of PUT and DELETE actions for mapping users to their groups.

type GroupId:

string

param GroupId:

[REQUIRED]

The identifier of the group required to check the processing of PUT and DELETE actions for mapping users to their groups.

rtype:

dict

returns:

Response Syntax

{
    'IndexId': 'string',
    'DataSourceId': 'string',
    'GroupId': 'string',
    'GroupOrderingIdSummaries': [
        {
            'Status': 'FAILED'|'SUCCEEDED'|'PROCESSING'|'DELETING'|'DELETED',
            'LastUpdatedAt': datetime(2015, 1, 1),
            'ReceivedAt': datetime(2015, 1, 1),
            'OrderingId': 123,
            'FailureReason': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • IndexId (string) --

      Shows the identifier of the index to see information on the processing of PUT and DELETE actions for mapping users to their groups.

    • DataSourceId (string) --

      Shows the identifier of the data source to see information on the processing of PUT and DELETE actions for mapping users to their groups.

    • GroupId (string) --

      Shows the identifier of the group to see information on the processing of PUT and DELETE actions for mapping users to their groups.

    • GroupOrderingIdSummaries (list) --

      Shows the following information on the processing of PUT and DELETE actions for mapping users to their groups:

      • Status – the status can be either PROCESSING, SUCCEEDED, DELETING, DELETED, or FAILED.

      • Last updated – the last date-time an action was updated.

      • Received – the last date-time an action was received or submitted.

      • Ordering ID – the latest action that should process and apply after other actions.

      • Failure reason – the reason an action could not be processed.

      • (dict) --

        Information on the processing of PUT and DELETE actions for mapping users to their groups.

        • Status (string) --

          The current processing status of actions for mapping users to their groups. The status can be either PROCESSING, SUCCEEDED, DELETING, DELETED, or FAILED.

        • LastUpdatedAt (datetime) --

          The last date-time an action was updated. An action can be a PUT or DELETE action for mapping users to their groups.

        • ReceivedAt (datetime) --

          The date-time an action was received by Amazon Kendra. An action can be a PUT or DELETE action for mapping users to their groups.

        • OrderingId (integer) --

          The order in which actions should complete processing. An action can be a PUT or DELETE action for mapping users to their groups.

        • FailureReason (string) --

          The reason an action could not be processed. An action can be a PUT or DELETE action for mapping users to their groups.

BatchPutDocument (updated) Link ¶
Changes (request)
{'Documents': {'AccessControlList': {'DataSourceId': 'string'},
               'HierarchicalAccessControlList': [{'PrincipalList': [{'Access': 'ALLOW '
                                                                               '| '
                                                                               'DENY',
                                                                     'DataSourceId': 'string',
                                                                     'Name': 'string',
                                                                     'Type': 'USER '
                                                                             '| '
                                                                             'GROUP'}]}]}}

Adds one or more documents to an index.

The BatchPutDocument operation enables you to ingest inline documents or a set of documents stored in an Amazon S3 bucket. Use this operation to ingest your text and unstructured text into an index, add custom attributes to the documents, and to attach an access control list to the documents added to the index.

The documents are indexed asynchronously. You can see the progress of the batch using Amazon Web Services CloudWatch. Any error messages related to processing the batch are sent to your Amazon Web Services CloudWatch log.

See also: AWS API Documentation

Request Syntax

client.batch_put_document(
    IndexId='string',
    RoleArn='string',
    Documents=[
        {
            'Id': 'string',
            'Title': 'string',
            'Blob': b'bytes',
            'S3Path': {
                'Bucket': 'string',
                'Key': 'string'
            },
            'Attributes': [
                {
                    'Key': 'string',
                    'Value': {
                        'StringValue': 'string',
                        'StringListValue': [
                            'string',
                        ],
                        'LongValue': 123,
                        'DateValue': datetime(2015, 1, 1)
                    }
                },
            ],
            'AccessControlList': [
                {
                    'Name': 'string',
                    'Type': 'USER'|'GROUP',
                    'Access': 'ALLOW'|'DENY',
                    'DataSourceId': 'string'
                },
            ],
            'HierarchicalAccessControlList': [
                {
                    'PrincipalList': [
                        {
                            'Name': 'string',
                            'Type': 'USER'|'GROUP',
                            'Access': 'ALLOW'|'DENY',
                            'DataSourceId': 'string'
                        },
                    ]
                },
            ],
            'ContentType': 'PDF'|'HTML'|'MS_WORD'|'PLAIN_TEXT'|'PPT'
        },
    ]
)
type IndexId:

string

param IndexId:

[REQUIRED]

The identifier of the index to add the documents to. You need to create the index first using the CreateIndex operation.

type RoleArn:

string

param RoleArn:

The Amazon Resource Name (ARN) of a role that is allowed to run the BatchPutDocument operation. For more information, see IAM Roles for Amazon Kendra.

type Documents:

list

param Documents:

[REQUIRED]

One or more documents to add to the index.

Documents can include custom attributes. For example, 'DataSourceId' and 'DataSourceSyncJobId' are custom attributes that provide information on the synchronization of documents running on a data source. Note, 'DataSourceSyncJobId' could be an optional custom attribute as Amazon Kendra will use the ID of a running sync job.

Documents have the following file size limits.

  • 5 MB total size for inline documents

  • 50 MB total size for files from an S3 bucket

  • 5 MB extracted text for any file

For more information about file size and transaction per second quotas, see Quotas.

  • (dict) --

    A document in an index.

    • Id (string) -- [REQUIRED]

      A unique identifier of the document in the index.

    • Title (string) --

      The title of the document.

    • Blob (bytes) --

      The contents of the document.

      Documents passed to the Blob parameter must be base64 encoded. Your code might not need to encode the document file bytes if you're using an Amazon Web Services SDK to call Amazon Kendra operations. If you are calling the Amazon Kendra endpoint directly using REST, you must base64 encode the contents before sending.

    • S3Path (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.

    • Attributes (list) --

      Custom attributes to apply to the document. Use the custom attributes to provide additional information for searching, to provide facets for refining searches, and to provide additional information in the query response.

      • (dict) --

        A custom attribute value assigned to a document.

        • 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.

            It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

    • AccessControlList (list) --

      Information on user and group access rights, which is used for user context filtering.

      • (dict) --

        Provides user and group information for document access filtering.

        • Name (string) -- [REQUIRED]

          The name of the user or group.

        • Type (string) -- [REQUIRED]

          The type of principal.

        • Access (string) -- [REQUIRED]

          Whether to allow or deny access to the principal.

        • DataSourceId (string) --

          The identifier of the data source the principal should access documents from.

    • HierarchicalAccessControlList (list) --

      The list of principal lists that define the hierarchy for which documents users should have access to.

      • (dict) --

        Information to define the hierarchy for which documents users should have access to.

        • PrincipalList (list) -- [REQUIRED]

          A list of principal lists that define the hierarchy for which documents users should have access to. Each hierarchical list specifies which user or group has allow or deny access for each document.

          • (dict) --

            Provides user and group information for document access filtering.

            • Name (string) -- [REQUIRED]

              The name of the user or group.

            • Type (string) -- [REQUIRED]

              The type of principal.

            • Access (string) -- [REQUIRED]

              Whether to allow or deny access to the principal.

            • DataSourceId (string) --

              The identifier of the data source the principal should access documents from.

    • ContentType (string) --

      The file type of the document in the Blob field.

rtype:

dict

returns:

Response Syntax

{
    'FailedDocuments': [
        {
            'Id': 'string',
            'ErrorCode': 'InternalError'|'InvalidRequest',
            'ErrorMessage': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • FailedDocuments (list) --

      A list of documents that were not added to the index because the document failed a validation check. Each document contains an error message that indicates why the document couldn't be added to the index.

      If there was an error adding a document to an index the error is reported in your Amazon Web Services CloudWatch log. For more information, see Monitoring Amazon Kendra with Amazon CloudWatch Logs

      • (dict) --

        Provides information about a document that could not be indexed.

        • Id (string) --

          The unique identifier of the document.

        • ErrorCode (string) --

          The type of error that caused the document to fail to be indexed.

        • ErrorMessage (string) --

          A description of the reason why the document could not be indexed.

Query (updated) Link ¶
Changes (request)
{'UserContext': {'DataSourceGroups': [{'DataSourceId': 'string',
                                       'GroupId': 'string'}],
                 'Groups': ['string'],
                 'UserId': 'string'}}

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',
    DocumentRelevanceOverrideConfigurations=[
        {
            'Name': 'string',
            'Relevance': {
                'Freshness': True|False,
                'Importance': 123,
                'Duration': 'string',
                'RankOrder': 'ASCENDING'|'DESCENDING',
                'ValueImportanceMap': {
                    'string': 123
                }
            }
        },
    ],
    PageNumber=123,
    PageSize=123,
    SortingConfiguration={
        'DocumentAttributeKey': 'string',
        'SortOrder': 'DESC'|'ASC'
    },
    UserContext={
        'Token': 'string',
        'UserId': 'string',
        'Groups': [
            'string',
        ],
        'DataSourceGroups': [
            {
                'GroupId': 'string',
                'DataSourceId': 'string'
            },
        ]
    },
    VisitorId='string'
)
type IndexId:

string

param IndexId:

[REQUIRED]

The unique identifier of the index to search. The identifier is returned in the response from the CreateIndex operation.

type QueryText:

string

param QueryText:

[REQUIRED]

The text to search for.

type AttributeFilter:

dict

param AttributeFilter:

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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • 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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • 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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • 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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • 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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • 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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

  • 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.

        It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

type Facets:

list

param Facets:

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.

type RequestedDocumentAttributes:

list

param RequestedDocumentAttributes:

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) --

type QueryResultTypeFilter:

string

param QueryResultTypeFilter:

Sets the type of query. Only results for the specified query type are returned.

type DocumentRelevanceOverrideConfigurations:

list

param DocumentRelevanceOverrideConfigurations:

Overrides relevance tuning configurations of fields or 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 at the index level, but you do not use this API to override any relevance tuning in the index, then Amazon Kendra uses the relevance tuning that is configured at the index level.

If there is relevance tuning configured for fields at the index level, but 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.

  • (dict) --

    Overrides the document relevance properties of a custom index field.

    • Name (string) -- [REQUIRED]

      The name of the tuning configuration to override document relevance at the index level.

    • Relevance (dict) -- [REQUIRED]

      Provides information for manually tuning the relevance of a field in a search. When a query includes terms that match the field, the results are given a boost in the response based on these tuning parameters.

      • Freshness (boolean) --

        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. You can only set the Freshness field on one DATE type field. Only applies to DATE fields.

      • Importance (integer) --

        The relative importance of the field in the search. Larger numbers provide more of a boost than smaller numbers.

      • Duration (string) --

        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 (string) --

        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 and DOUBLE fields.

      • ValueImportanceMap (dict) --

        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 the regular importance for the boost.

        • (string) --

          • (integer) --

type PageNumber:

integer

param PageNumber:

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.

type PageSize:

integer

param PageSize:

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.

type SortingConfiguration:

dict

param SortingConfiguration:

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.

type UserContext:

dict

param UserContext:

The user context token.

  • Token (string) --

    The user context token for filtering search results for a user. It must be a JWT or a JSON token.

  • UserId (string) --

    The identifier of the user you want to filter search results based on their access to documents.

  • Groups (list) --

    The list of groups you want to filter search results based on the groups' access to documents.

    • (string) --

  • DataSourceGroups (list) --

    The list of data source groups you want to filter search results based on groups' access to documents in that data source.

    • (dict) --

      Data source information for user context filtering.

      • GroupId (string) -- [REQUIRED]

        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 (string) -- [REQUIRED]

        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.

type VisitorId:

string

param VisitorId:

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.

rtype:

dict

returns:

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.

                It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

        • 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.

                It is important for the time zone to be included in the ISO 8601 date-time format. For example, 20120325T123010+01:00 is the ISO 8601 date-time format for March 25th 2012 at 12:30PM (plus 10 seconds) in Central European Time.

            • 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.