Step 5: Querying the Amazon Kendra index
Your Amazon Kendra index is now ready for natural language queries. When you search your index, Amazon Kendra uses all the data and metadata you provided to return the most accurate answers to your search query.
There are three kinds of queries that Amazon Kendra can answer:
-
Factoid queries ("who", "what", "when", or "where" questions)
-
Descriptive queries ("how" questions)
-
Keyword searches (questions whose intent and scope are not clear)
Querying your Amazon Kendra index
You can query your Amazon Kendra index using questions that correspond to the three kinds of queries that Amazon Kendra supports. For more information, see Queries.
The example questions in this section have been chosen based on the sample dataset.
-
Open the Amazon Kendra console at https://console.aws.amazon.com/kendra/
. -
From the Indexes list, click on
kendra-index
. -
From the left navigation menu, choose the option to search your index.
-
To run a sample factoid query, enter
Who is Lewis Hamilton?
in the search box and press enter.The first returned result is the Amazon Kendra suggested answer, together with the data file containing the answer. The rest of the results form the set of recommended documents.
-
To run a descriptive query, enter
How does Formula One work?
in the search box and press enter.You will see another result returned by the Amazon Kendra console, this time with the relevant phrase highlighted.
-
To run a keyword search, enter
Formula One
in the search box and press enter.You will see another result returned by the Amazon Kendra console, followed by the results for all other mentions of the phrase in the dataset.
-
To run a sample factoid query, use the query
command: The AWS CLI displays the results of your query.
-
To run a sample descriptive query, use the query
command: The AWS CLI displays the results to your query.
-
To run a sample keyword search, use the query
command: The AWS CLI displays the returned answers to your query.
Filtering your search results
You can filter and sort your search results using custom document attributes in the Amazon Kendra console. For more information on how Amazon Kendra processes queries, see Filtering queries.
-
Open the Amazon Kendra console at https://console.aws.amazon.com/kendra/
. -
From the Indexes list, click on
kendra-index
. -
From the left navigation menu, choose the option to search your index.
-
In the search box, enter
Soccer matches
as a query and press enter. -
From the left navigation menu, choose Filter search results to see a list of facets you can use to filter your search.
-
Select the check box for "Champions League" under the EVENT subheading, to see your search results filtered only by the results containing "Champions League".
-
To see the entities of a specific type (such as
EVENT
) that are available for a search, use the querycommand: The AWS CLI displays the search results. To get a list of facets of type
EVENT
, navigate to the "FacetResults" section of the AWS CLI output to see a list of filterable facets with their counts. For example, one of the facets is "Champions League".Note
Instead of
EVENT
, you can choose any of the index fields you created in Creating an Amazon Kendra index for theDocumentAttributeKey
value. -
To run the same search but filter only by the results containing "Champions League", use the query
command: The AWS CLI displays the filtered search results.