Class for interacting with Amazon Kendra, an intelligent search service provided by AWS. Extends the BaseRetriever class.


const retriever = new AmazonKendraRetriever({
topK: 10,
indexId: "YOUR_INDEX_ID",
region: "us-east-2",
clientOptions: {
credentials: {
accessKeyId: "YOUR_ACCESS_KEY_ID",
secretAccessKey: "YOUR_SECRET_ACCESS_KEY",

const docs = await retriever.getRelevantDocuments("How are clouds formed?");

Hierarchy (view full)



indexId: string
kendraClient: KendraClient
topK: number
attributeFilter?: AttributeFilter


  • Combines title and excerpt into a single string.


    • Optional title: string

      The title of the document.

    • Optional excerpt: string

      An excerpt from the document.

    Returns string

    A single string combining the title and excerpt.

  • Extracts the attribute value from a DocumentAttributeValue object.


    • value: DocumentAttributeValue

      The DocumentAttributeValue object to extract the value from.

    Returns string | number | string[] | Date

    The extracted attribute value.

  • Extracts the attribute key-value pairs from an array of DocumentAttribute objects.


    • Optional documentAttributes: DocumentAttribute[]

      The array of DocumentAttribute objects to extract the key-value pairs from.

    Returns {
        [key: string]: unknown;

    An object containing the extracted attribute key-value pairs.

    • [key: string]: unknown
  • Extracts the top-k documents from a QueryCommandOutput object.


    • response: QueryCommandOutput

      The QueryCommandOutput object to extract the documents from.

    • pageSize: number

      The number of documents to extract.

    Returns any[]

    An array of Document objects.

  • Extracts the top-k documents from a RetrieveCommandOutput object.


    • response: RetrieveCommandOutput

      The RetrieveCommandOutput object to extract the documents from.

    • pageSize: number

      The number of documents to extract.

    Returns Document[]

    An array of Document objects.

  • Sends a retrieve or query request to Kendra and returns the top-k documents.


    • query: string

      The query to send to Kendra.

    • topK: number

      The number of top documents to return.

    • Optional attributeFilter: AttributeFilter

      Optional filter to apply when retrieving documents.

    Returns Promise<any[]>

    A Promise that resolves to an array of Document objects.

Generated using TypeDoc