Skip to content

AWS.Kendra reference

Source: src/AWS/Kendra/BatchDeleteDocument.ts

Runtime binding for the BatchDeleteDocument operation (IAM action kendra:BatchDeleteDocument), scoped to one Index.

Removes documents from the index by id. Check the response’s FailedDocuments for per-document errors. Provide the implementation with Effect.provide(AWS.Kendra.BatchDeleteDocumentHttp).

const deleteDocuments = yield* AWS.Kendra.BatchDeleteDocument(index);
yield* deleteDocuments({ DocumentIdList: ["welcome"] });

Source: src/AWS/Kendra/BatchGetDocumentStatus.ts

Runtime binding for the BatchGetDocumentStatus operation (IAM action kendra:BatchGetDocumentStatus), scoped to one Index.

Returns the indexing status (INDEXED, PROCESSING, FAILED, …) of documents added with BatchPutDocument or a data-source sync. Provide the implementation with Effect.provide(AWS.Kendra.BatchGetDocumentStatusHttp).

BatchGetDocumentStatus: Indexing Documents

Section titled “BatchGetDocumentStatus: Indexing Documents”
const documentStatus = yield* AWS.Kendra.BatchGetDocumentStatus(index);
const status = yield* documentStatus({
DocumentInfoList: [{ DocumentId: "welcome" }],
});
console.log(status.DocumentStatusList?.[0]?.DocumentStatus);

Source: src/AWS/Kendra/BatchPutDocument.ts

Runtime binding for the BatchPutDocument operation (IAM action kendra:BatchPutDocument), scoped to one Index.

Adds documents directly to the index (inline blobs or S3 paths) — the push-API alternative to a data-source sync. Check the response’s FailedDocuments for per-document errors; documents index asynchronously (poll with BatchGetDocumentStatus). Provide the implementation with Effect.provide(AWS.Kendra.BatchPutDocumentHttp).

const putDocuments = yield* AWS.Kendra.BatchPutDocument(index);
const result = yield* putDocuments({
Documents: [
{
Id: "welcome",
Title: "Welcome",
Blob: new TextEncoder().encode("Hello from Alchemy"),
ContentType: "PLAIN_TEXT",
},
],
});
// result.FailedDocuments is empty on success

Source: src/AWS/Kendra/ClearQuerySuggestions.ts

Runtime binding for the ClearQuerySuggestions operation (IAM action kendra:ClearQuerySuggestions), scoped to one Index.

Clears existing query suggestions for the index. Suggestions rebuild from new query traffic (which can take up to 24 hours). Provide the implementation with Effect.provide(AWS.Kendra.ClearQuerySuggestionsHttp).

const clearSuggestions = yield* AWS.Kendra.ClearQuerySuggestions(index);
yield* clearSuggestions();

Source: src/AWS/Kendra/CreateAccessControlConfiguration.ts

Runtime binding for the CreateAccessControlConfiguration operation (IAM action kendra:CreateAccessControlConfiguration), scoped to one Index.

Creates a named access-control configuration (user/group ACLs) on the index. Kendra designed this for runtime use: re-apply access changes to documents at query time without re-indexing them — e.g. revoke a departed user’s access, then reference the returned Id from a document’s AccessControlConfigurationId. Provide the implementation with Effect.provide(AWS.Kendra.CreateAccessControlConfigurationHttp).

CreateAccessControlConfiguration: Access Control Configurations

Section titled “CreateAccessControlConfiguration: Access Control Configurations”
const createAcl =
yield* AWS.Kendra.CreateAccessControlConfiguration(index);
const { Id } = yield* createAcl({
Name: "block-departed-users",
AccessControlList: [
{ Name: "departed-user", Type: "USER", Access: "DENY" },
],
});

Source: src/AWS/Kendra/DataSource.ts

An Amazon Kendra data source — a connector that syncs documents from a repository (S3 bucket, SharePoint, website, …) into a Kendra index.

S3 Data Source

import * as AWS from "alchemy/AWS";
const source = yield* AWS.Kendra.DataSource("Docs", {
indexId: index.id,
type: "S3",
roleArn: dataSourceRole.roleArn,
configuration: {
S3Configuration: {
BucketName: bucket.bucketName,
},
},
});

Scheduled Sync

const source = yield* AWS.Kendra.DataSource("Docs", {
indexId: index.id,
type: "S3",
roleArn: dataSourceRole.roleArn,
schedule: "cron(0 12 * * ? *)",
configuration: {
S3Configuration: { BucketName: bucket.bucketName },
},
});

Source: src/AWS/Kendra/DeleteAccessControlConfiguration.ts

Runtime binding for the DeleteAccessControlConfiguration operation (IAM action kendra:DeleteAccessControlConfiguration), scoped to one Index.

Deletes an access-control configuration from the index. Provide the implementation with Effect.provide(AWS.Kendra.DeleteAccessControlConfigurationHttp).

DeleteAccessControlConfiguration: Access Control Configurations

Section titled “DeleteAccessControlConfiguration: Access Control Configurations”
const deleteAcl =
yield* AWS.Kendra.DeleteAccessControlConfiguration(index);
yield* deleteAcl({ Id: configurationId });

Source: src/AWS/Kendra/DeletePrincipalMapping.ts

Runtime binding for the DeletePrincipalMapping operation (IAM action kendra:DeletePrincipalMapping), scoped to one Index.

Deletes a group’s user-to-group mapping created with PutPrincipalMapping. Provide the implementation with Effect.provide(AWS.Kendra.DeletePrincipalMappingHttp).

const deleteMapping = yield* AWS.Kendra.DeletePrincipalMapping(index);
yield* deleteMapping({ GroupId: "engineering" });

Source: src/AWS/Kendra/DescribeAccessControlConfiguration.ts

Runtime binding for the DescribeAccessControlConfiguration operation (IAM action kendra:DescribeAccessControlConfiguration), scoped to one Index.

Reads one access-control configuration of the index. Provide the implementation with Effect.provide(AWS.Kendra.DescribeAccessControlConfigurationHttp).

DescribeAccessControlConfiguration: Access Control Configurations

Section titled “DescribeAccessControlConfiguration: Access Control Configurations”
const describeAcl =
yield* AWS.Kendra.DescribeAccessControlConfiguration(index);
const acl = yield* describeAcl({ Id: configurationId });
console.log(acl.Name, acl.AccessControlList);

Source: src/AWS/Kendra/DescribePrincipalMapping.ts

Runtime binding for the DescribePrincipalMapping operation (IAM action kendra:DescribePrincipalMapping), scoped to one Index.

Describes the processing state of the PUT/DELETE actions applied to a group’s principal mapping. Provide the implementation with Effect.provide(AWS.Kendra.DescribePrincipalMappingHttp).

DescribePrincipalMapping: Principal Mapping

Section titled “DescribePrincipalMapping: Principal Mapping”
const describeMapping = yield* AWS.Kendra.DescribePrincipalMapping(index);
const mapping = yield* describeMapping({ GroupId: "engineering" });
console.log(mapping.GroupOrderingIdSummaries);

Source: src/AWS/Kendra/DescribeQuerySuggestionsConfig.ts

Runtime binding for the DescribeQuerySuggestionsConfig operation (IAM action kendra:DescribeQuerySuggestionsConfig), scoped to one Index.

Reads the index’s query-suggestions settings (mode, query-log look-back window, attribute-suggestions config, …). Provide the implementation with Effect.provide(AWS.Kendra.DescribeQuerySuggestionsConfigHttp).

DescribeQuerySuggestionsConfig: Query Suggestions

Section titled “DescribeQuerySuggestionsConfig: Query Suggestions”
const suggestionsConfig =
yield* AWS.Kendra.DescribeQuerySuggestionsConfig(index);
const config = yield* suggestionsConfig();
console.log(config.Mode, config.Status);

Source: src/AWS/Kendra/GetQuerySuggestions.ts

Runtime binding for the GetQuerySuggestions operation (IAM action kendra:GetQuerySuggestions), scoped to one Index.

Fetches typeahead query suggestions for a partial query string, based on the index’s query history and/or document fields. Provide the implementation with Effect.provide(AWS.Kendra.GetQuerySuggestionsHttp).

const suggest = yield* AWS.Kendra.GetQuerySuggestions(index);
const { Suggestions } = yield* suggest({ QueryText: "how to conf" });

Source: src/AWS/Kendra/GetSnapshots.ts

Runtime binding for the GetSnapshots operation (IAM action kendra:GetSnapshots), scoped to one Index.

Fetches search-analytics metric snapshots for the index (click-through rate, zero-result queries, top queries, …) over a time interval. Provide the implementation with Effect.provide(AWS.Kendra.GetSnapshotsHttp).

const getSnapshots = yield* AWS.Kendra.GetSnapshots(index);
const metrics = yield* getSnapshots({
Interval: "ONE_WEEK_AGO",
MetricType: "QUERIES_BY_COUNT",
});

Source: src/AWS/Kendra/ListAccessControlConfigurations.ts

Runtime binding for the ListAccessControlConfigurations operation (IAM action kendra:ListAccessControlConfigurations), scoped to one Index.

Lists the index’s access-control configurations. Provide the implementation with Effect.provide(AWS.Kendra.ListAccessControlConfigurationsHttp).

ListAccessControlConfigurations: Access Control Configurations

Section titled “ListAccessControlConfigurations: Access Control Configurations”
const listAcls =
yield* AWS.Kendra.ListAccessControlConfigurations(index);
const { AccessControlConfigurations } = yield* listAcls();

Source: src/AWS/Kendra/ListDataSourceSyncJobs.ts

Runtime binding for the ListDataSourceSyncJobs operation (IAM action kendra:ListDataSourceSyncJobs), scoped to one DataSource.

Lists the data source’s sync-job history — status, error details, and per-run document add/modify/delete/fail metrics. Provide the implementation with Effect.provide(AWS.Kendra.ListDataSourceSyncJobsHttp).

ListDataSourceSyncJobs: Syncing Data Sources

Section titled “ListDataSourceSyncJobs: Syncing Data Sources”
const listSyncJobs = yield* AWS.Kendra.ListDataSourceSyncJobs(source);
const jobs = yield* listSyncJobs({ StatusFilter: "SUCCEEDED" });
console.log(jobs.History?.[0]?.Metrics);

Source: src/AWS/Kendra/ListGroupsOlderThanOrderingId.ts

Runtime binding for the ListGroupsOlderThanOrderingId operation (IAM action kendra:ListGroupsOlderThanOrderingId), scoped to one Index.

Lists groups whose principal mapping is older than the given ordering id — used to find stale group mappings to refresh or delete. Provide the implementation with Effect.provide(AWS.Kendra.ListGroupsOlderThanOrderingIdHttp).

ListGroupsOlderThanOrderingId: Principal Mapping

Section titled “ListGroupsOlderThanOrderingId: Principal Mapping”
const listGroups = yield* AWS.Kendra.ListGroupsOlderThanOrderingId(index);
const stale = yield* listGroups({ OrderingId: orderingId });
console.log(stale.GroupsSummaries);

Source: src/AWS/Kendra/PutPrincipalMapping.ts

Runtime binding for the PutPrincipalMapping operation (IAM action kendra:PutPrincipalMapping), scoped to one Index.

Maps users to groups (optionally per data source) so queries filtered on the user’s context only return documents that user’s groups may access. Provide the implementation with Effect.provide(AWS.Kendra.PutPrincipalMappingHttp).

const putPrincipalMapping = yield* AWS.Kendra.PutPrincipalMapping(index);
yield* putPrincipalMapping({
GroupId: "engineering",
GroupMembers: {
MemberUsers: [{ UserId: "user@example.com" }],
},
});

Source: src/AWS/Kendra/Query.ts

Runtime binding for the Query operation (IAM action kendra:Query), scoped to one Index.

Searches the index with a natural-language query — returns ranked answers, FAQ matches, and document results, optionally filtered on document attributes and the querying user’s context. Provide the implementation with Effect.provide(AWS.Kendra.QueryHttp).

const query = yield* AWS.Kendra.Query(index);
const results = yield* query({ QueryText: "how do I configure SSO?" });
for (const item of results.ResultItems ?? []) {
console.log(item.Type, item.DocumentTitle?.Text);
}

Source: src/AWS/Kendra/Retrieve.ts

Runtime binding for the Retrieve operation (IAM action kendra:Retrieve), scoped to one Index.

Retrieves up to 100 semantically-relevant passages (200-token excerpts) from the index — the building block for retrieval-augmented generation (RAG) over documents synced into Kendra. Provide the implementation with Effect.provide(AWS.Kendra.RetrieveHttp).

const retrieve = yield* AWS.Kendra.Retrieve(index);
const passages = yield* retrieve({ QueryText: "vacation policy" });
const context = (passages.ResultItems ?? [])
.map((item) => item.Content)
.join("\n");

Source: src/AWS/Kendra/SearchIndex.ts

An Amazon Kendra index — a machine-learning powered enterprise search index that data sources (S3, SharePoint, databases, …) sync documents into and that applications query with natural language.

import * as AWS from "alchemy/AWS";
const role = yield* AWS.IAM.Role("KendraRole", {
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: { Service: "kendra.amazonaws.com" },
Action: "sts:AssumeRole",
}],
},
policies: [{
policyName: "logs",
policyDocument: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Action: ["logs:*", "cloudwatch:PutMetricData"],
Resource: "*",
}],
},
}],
});
const index = yield* AWS.Kendra.Index("Search", {
edition: "DEVELOPER_EDITION",
roleArn: role.roleArn,
});

Source: src/AWS/Kendra/StartDataSourceSyncJob.ts

Runtime binding for the StartDataSourceSyncJob operation (IAM action kendra:StartDataSourceSyncJob), scoped to one DataSource.

Starts an on-demand sync of the data source into its index — the programmatic alternative to the data source’s cron schedule. Fails with ResourceInUseException while another sync is already running. Provide the implementation with Effect.provide(AWS.Kendra.StartDataSourceSyncJobHttp).

StartDataSourceSyncJob: Syncing Data Sources

Section titled “StartDataSourceSyncJob: Syncing Data Sources”
const startSync = yield* AWS.Kendra.StartDataSourceSyncJob(source);
const { ExecutionId } = yield* startSync();

Source: src/AWS/Kendra/StopDataSourceSyncJob.ts

Runtime binding for the StopDataSourceSyncJob operation (IAM action kendra:StopDataSourceSyncJob), scoped to one DataSource.

Stops the data source’s currently-running sync job, if any. Provide the implementation with Effect.provide(AWS.Kendra.StopDataSourceSyncJobHttp).

StopDataSourceSyncJob: Syncing Data Sources

Section titled “StopDataSourceSyncJob: Syncing Data Sources”
const stopSync = yield* AWS.Kendra.StopDataSourceSyncJob(source);
yield* stopSync();

Source: src/AWS/Kendra/SubmitFeedback.ts

Runtime binding for the SubmitFeedback operation (IAM action kendra:SubmitFeedback), scoped to one Index.

Submits click and relevance feedback for a query’s results — Kendra uses it to tune the index’s relevance over time (incremental learning). Provide the implementation with Effect.provide(AWS.Kendra.SubmitFeedbackHttp).

const submitFeedback = yield* AWS.Kendra.SubmitFeedback(index);
yield* submitFeedback({
QueryId: queryId,
ClickFeedbackItems: [{ ResultId: resultId, ClickTime: new Date() }],
});

Source: src/AWS/Kendra/UpdateAccessControlConfiguration.ts

Runtime binding for the UpdateAccessControlConfiguration operation (IAM action kendra:UpdateAccessControlConfiguration), scoped to one Index.

Updates an access-control configuration’s name, description, or user/group ACLs. Provide the implementation with Effect.provide(AWS.Kendra.UpdateAccessControlConfigurationHttp).

UpdateAccessControlConfiguration: Access Control Configurations

Section titled “UpdateAccessControlConfiguration: Access Control Configurations”
const updateAcl =
yield* AWS.Kendra.UpdateAccessControlConfiguration(index);
yield* updateAcl({
Id: configurationId,
AccessControlList: [{ Name: "sam", Type: "USER", Access: "ALLOW" }],
});

Source: src/AWS/Kendra/UpdateQuerySuggestionsConfig.ts

Runtime binding for the UpdateQuerySuggestionsConfig operation (IAM action kendra:UpdateQuerySuggestionsConfig), scoped to one Index.

Tunes the index’s query-suggestions settings — switch between ENABLED and LEARN_ONLY, adjust the query-log look-back window, or change minimum query thresholds. Provide the implementation with Effect.provide(AWS.Kendra.UpdateQuerySuggestionsConfigHttp).

UpdateQuerySuggestionsConfig: Query Suggestions

Section titled “UpdateQuerySuggestionsConfig: Query Suggestions”
const updateSuggestions =
yield* AWS.Kendra.UpdateQuerySuggestionsConfig(index);
yield* updateSuggestions({
Mode: "LEARN_ONLY",
queryLogLookBackWindow: "14 days",
MinimumNumberOfQueryingUsers: 2,
});