What is @aws-sdk/client-kendra?
@aws-sdk/client-kendra is an AWS SDK for JavaScript package that allows developers to interact with Amazon Kendra, a highly accurate and easy-to-use enterprise search service powered by machine learning. This package provides methods to create, manage, and query indexes, data sources, and other resources within Amazon Kendra.
What are @aws-sdk/client-kendra's main functionalities?
Create Index
This feature allows you to create a new index in Amazon Kendra. The code sample demonstrates how to use the CreateIndexCommand to create an index with a specified name, role ARN, and edition.
const { KendraClient, CreateIndexCommand } = require('@aws-sdk/client-kendra');
const client = new KendraClient({ region: 'us-west-2' });
const params = {
Name: 'MyIndex',
RoleArn: 'arn:aws:iam::123456789012:role/service-role/AmazonKendra-role',
Edition: 'DEVELOPER_EDITION'
};
const run = async () => {
try {
const data = await client.send(new CreateIndexCommand(params));
console.log('Index created:', data);
} catch (err) {
console.error('Error creating index:', err);
}
};
run();
Query Index
This feature allows you to query an existing index in Amazon Kendra. The code sample demonstrates how to use the QueryCommand to search an index using a specified query text.
const { KendraClient, QueryCommand } = require('@aws-sdk/client-kendra');
const client = new KendraClient({ region: 'us-west-2' });
const params = {
IndexId: 'index-id',
QueryText: 'search query'
};
const run = async () => {
try {
const data = await client.send(new QueryCommand(params));
console.log('Query results:', data);
} catch (err) {
console.error('Error querying index:', err);
}
};
run();
List Data Sources
This feature allows you to list all data sources associated with a specific index in Amazon Kendra. The code sample demonstrates how to use the ListDataSourcesCommand to retrieve and display the data sources.
const { KendraClient, ListDataSourcesCommand } = require('@aws-sdk/client-kendra');
const client = new KendraClient({ region: 'us-west-2' });
const params = {
IndexId: 'index-id'
};
const run = async () => {
try {
const data = await client.send(new ListDataSourcesCommand(params));
console.log('Data sources:', data);
} catch (err) {
console.error('Error listing data sources:', err);
}
};
run();
Other packages similar to @aws-sdk/client-kendra
elasticsearch
The 'elasticsearch' npm package is a client for Elasticsearch, a distributed, RESTful search and analytics engine. It provides similar functionalities for creating and managing indexes, querying data, and handling data sources. However, Elasticsearch is a self-managed service, whereas Amazon Kendra is a fully managed service provided by AWS.
algoliasearch
The 'algoliasearch' npm package is a client for Algolia, a hosted search engine capable of delivering real-time results from the first keystroke. It offers functionalities for managing indexes and querying data similar to Amazon Kendra. Algolia is known for its speed and ease of integration, but it is a third-party service compared to the AWS-native Kendra.
typesense
The 'typesense' npm package is a client for Typesense, an open-source, typo-tolerant search engine optimized for instant search experiences. It provides similar functionalities for managing and querying indexes. Typesense is self-hosted and offers a different set of features and performance characteristics compared to the fully managed Amazon Kendra.