Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Using the Amazon Kendra API to submit feedback

Focus mode
Using the Amazon Kendra API to submit feedback - Amazon Kendra

To use the Amazon Kendra API to submit query feedback, use the SubmitFeedback API. To identify the query, you supply the index ID of the index that the query applies to, and the query ID returned in the response from the Query API.

The following example shows how to submit click and relevance feedback using the Amazon Kendra API. You can submit multiple sets of feedback through the ClickFeedbackItems and RelevanceFeedbackItems arrays. This example submits a single click and a single relevance feedback item. The feedback submittal uses the current time.

To submit feedback for a search (AWS SDK)
  1. You can use the following example code with the required values:

    1. index id—The ID of the index that the query applies to.

    2. query id—The query that you want to provide feedback on.

    3. result id—The ID of the query result that you want to provide feedback on. The query response contains the result ID.

    4. relevance value—Either RELEVANT (the query result is relevant) or NOT_RELEVANT (the query result is not relevant).

    Python
    import boto3 import time kendra = boto3.client("kendra") # Provide the index ID index_id = "index-id" # Provide the query ID query_id = "query-id" # Provide the search result ID result_id = "result-id" # Configure the feedback item feedback_item = {"ClickTime": int(time.time()), "ResultId":result_id} # Configure the relevance value relevance_value = "RELEVANT" relevance_item = {"RelevanceValue": relevance_value, "ResultId": result_id } response = kendra.submit_feedback( QueryId = query_id, IndexId = index_id, ClickFeedbackItems = [feedback_item], RelevanceFeedbackItems = [relevance_item] ) print("Submitted feedback for query: " + query_id)
    Java
    package com.amazonaws.kendra; import java.time.Instant; import software.amazon.awssdk.services.kendra.KendraClient; import software.amazon.awssdk.services.kendra.model.ClickFeedback; import software.amazon.awssdk.services.kendra.model.RelevanceFeedback; import software.amazon.awssdk.services.kendra.model.RelevanceType; import software.amazon.awssdk.services.kendra.model.SubmitFeedbackRequest; import software.amazon.awssdk.services.kendra.model.SubmitFeedbackResponse; public class SubmitFeedbackExample { public static void main(String[] args) { KendraClient kendra = KendraClient.builder().build(); SubmitFeedbackRequest submitFeedbackRequest = SubmitFeedbackRequest .builder() .indexId("IndexId") .queryId("QueryId") .clickFeedbackItems( ClickFeedback .builder() .clickTime(Instant.now()) .resultId("ResultId") .build()) .relevanceFeedbackItems( RelevanceFeedback .builder() .relevanceValue(RelevanceType.RELEVANT) .resultId("ResultId") .build()) .build(); SubmitFeedbackResponse response = kendra.submitFeedback(submitFeedbackRequest); System.out.println("Feedback is submitted"); } }
    import boto3 import time kendra = boto3.client("kendra") # Provide the index ID index_id = "index-id" # Provide the query ID query_id = "query-id" # Provide the search result ID result_id = "result-id" # Configure the feedback item feedback_item = {"ClickTime": int(time.time()), "ResultId":result_id} # Configure the relevance value relevance_value = "RELEVANT" relevance_item = {"RelevanceValue": relevance_value, "ResultId": result_id } response = kendra.submit_feedback( QueryId = query_id, IndexId = index_id, ClickFeedbackItems = [feedback_item], RelevanceFeedbackItems = [relevance_item] ) print("Submitted feedback for query: " + query_id)
  2. Run the code. After the feedback has been submitted, the code displays a message.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.