Filtering queries in Amazon Kendra

A feature you can use in order to improve your search results is the ability to filter your query results through document attributes. For example, in this case, we have defined the attribute _category, so you can submit a search query that filters the result to a specific whitepapers category. Filtering is helpful, for example, in chatbot scenarios where you want to ask the user before the search which product they are interested in, or, if you know a user is interested in a particular department and want to scope the results for that user. Filtering on attributes is possible independently of an attribute being facetable.

Facets are scoped views of a set of search results. So in the case of the attribute _category, you can use facets to offer your users the ability to choose to select a specific whitepapers category. If the user selects a particular whitepaper category, it will submit a filtered query with the whitepaper category.

In order to enable an attribute to be returned in the query as a FacetResult, you need to enable faceting for that specific field on the Facets definition page.

On the Facet definition page in the Amazon Kendra console, you will find 4 options:

  • Facetable: Indicates that the field can be used to create search facets, a count of results for each value in the field. The default is false .

  • Searchable: Determines whether the field is used in the search. If the Searchable field is true, you can use relevance tuning to manually tune how Amazon Kendra weights the field in the search. The default is true for string fields and false for number and date fields.

  • Displayable: Determines whether the field is returned in the query response. The default is true.

  • Sortable: Determines whether the field can be used to sort the results of a query. If you specify sorting on a field that does not have Sortable set to true, Amazon Kendra returns an exception. The default is false.