JavaScript code samples for Azure Cognitive Search

Learn about the JavaScript code samples that demonstrate the functionality and workflow of an Azure Cognitive Search solution. These samples use the Azure Cognitive Search client library for the Azure SDK for JavaScript, which you can explore through the following links.

Target Link
Package download www.npmjs.com/package/@azure/search-documents
API reference @azure/search-documents
API test cases github.com/Azure/azure-sdk-for-js/tree/master/sdk/search/search-documents/test
Source code github.com/Azure/azure-sdk-for-js/tree/master/sdk/search/search-documents

SDK samples

Code samples from the Azure SDK development team demonstrate API usage. You can find these samples in azure-sdk-for-js/tree/master/sdk/search/search-documents/samples on GitHub.

JavaScript SDK samples

Samples Description
indexes Demonstrates how to create, update, get, list, and delete search indexes. This sample category also includes a service statistic sample.
dataSourceConnections (for indexers) Demonstrates how to create, update, get, list, and delete indexer data sources, required for indexer-based indexing of supported Azure data sources.
indexers Demonstrates how to create, update, get, list, reset, and delete indexers.
skillSet Demonstrates how to create, update, get, list, and delete skillsets that are attached indexers, and that perform AI-based enrichment during indexing.
synonymMaps Demonstrates how to create, update, get, list, and delete synonym maps.

TypeScript samples

Samples Description
indexes Demonstrates how to create, update, get, list, and delete search indexes. This sample category also includes a service statistic sample.
dataSourceConnections (for indexers) Demonstrates how to create, update, get, list, and delete indexer data sources, required for indexer-based indexing of supported Azure data sources.
indexers Demonstrates how to create, update, get, list, reset, and delete indexers.
skillSet Demonstrates how to create, update, get, list, and delete skillsets that are attached indexers, and that perform AI-based enrichment during indexing.
synonymMaps Demonstrates how to create, update, get, list, and delete synonym maps.

Doc samples

Code samples from the Cognitive Search team demonstrate features and workflows. Many of these samples are referenced in tutorials, quickstarts, and how-to articles. You can find these samples in Azure-Samples/azure-search-javascript-samples on GitHub.

Samples Article
quickstart Source code for Quickstart: Create a search index in JavaScript. Covers the basic workflow for creating, loading, and querying a search index using sample data.
search-website Source code for Tutorial: Add search to web apps. Demonstrates an end-to-end search app that includes a rich client plus components for hosting the app and handling search requests.

Tip

Try the Samples browser to search for Microsoft code samples in GitHub, filtered by product, service, and language.

Other samples

The following samples are also published by the Cognitive Search team, but are not referenced in documentation. Associated readme files provide usage instructions.

Samples Description
azure-search-react-template React template for Azure Cognitive Search (github.com)