azure-search-documents-ts – DevOps & Infrastructure skill for AI agents
Build search applications with vector, hybrid, and semantic search capabilities.
Install the azure-search-documents-ts skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-search-documents-ts-56b8e.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /azure-search-documents-ts – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-search-documents-ts-56b8e.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $azure-search-documents-ts – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-search-documents-ts-56b8e.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /azure-search-documents-ts – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-search-documents-ts-56b8e.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /azure-search-documents-ts – then describe the task you want done.
SKILL.md content
Azure AI Search SDK for TypeScript
Build search applications with vector, hybrid, and semantic search capabilities.
Installation
npm install @azure/search-documents @azure/identityEnvironment Variables
AZURE_SEARCH_ENDPOINT=https://<service-name>.search.windows.net
AZURE_SEARCH_INDEX_NAME=my-index
AZURE_SEARCH_ADMIN_KEY=<admin-key> # Optional if using Entra IDAuthentication
import { SearchClient, SearchIndexClient } from "@azure/search-documents";
import { DefaultAzureCredential } from "@azure/identity";
const endpoint = process.env.AZURE_SEARCH_ENDPOINT!;
const indexName = process.env.AZURE_SEARCH_INDEX_NAME!;
const credential = new DefaultAzureCredential();
// For searching
const searchClient = new SearchClient(endpoint, indexName, credential);
// For index management
const indexClient = new SearchIndexClient(endpoint, credential);Version, schema and authorization
Snippets are independent fragments with placeholders, not a complete runnable program. Verify installed SDK types, actual index schema and embedding model/dimension before use. Set document security filters server-side from authenticated identity; never trust client-supplied filters as access control. Creating/updating indexes or uploading/deleting records needs exact target authorization and can change paid service state.
Core Workflow
Create Index with Vector Field
import { SearchIndex, SearchField, VectorSearch } from "@azure/search-documents";
const index: SearchIndex = {
name: "products",
fields: [
{ name: "id", type: "Edm.String", key: true },
{ name: "title", type: "Edm.String", searchable: true },
{ name: "description", type: "Edm.String", searchable: true },
{ name: "category", type: "Edm.String", filterable: true, facetable: true },
{
name: "embedding",
type: "Collection(Edm.Single)",
searchable: true,
vectorSearchDimensions: 1536,
vectorSearchProfileName: "vector-profile",
},
],
vectorSearch: {
algorithms: [
{ name: "hnsw-algorithm", kind: "hnsw" },
],
profiles: [
{ name: "vector-profile", algorithmConfigurationName: "hnsw-algorithm" },
],
},
};
await indexClient.createOrUpdateIndex(index);Index Documents
const documents = [
{ id: "1", title: "Widget", description: "A useful widget", category: "Tools", embedding: [...] },
{ id: "2", title: "Gadget", description: "A cool gadget", category: "Electronics", embedding: [...] },
];
const result = await searchClient.uploadDocuments(documents);
const failures = result.results.filter((item) => !item.succeeded);
if (failures.length) throw new Error(`Indexing failed for ${failures.length} documents`);
console.log(`Indexed ${result.results.length} documents`);Full-Text Search
const results = await searchClient.search("widget", {
select: ["id", "title", "description"],
filter: "category eq 'Tools'",
orderBy: ["title asc"],
top: 10,
});
for await (const result of results.results) {
console.log(`${result.document.title}: ${result.score}`);
}Vector Search
const queryVector = await getEmbedding("useful tool"); // Your embedding function
const results = await searchClient.search("*", {
vectorSearchOptions: {
queries: [
{
kind: "vector",
vector: queryVector,
fields: ["embedding"],
kNearestNeighborsCount: 10,
},
],
},
select: ["id", "title", "description"],
});
for await (const result of results.results) {
console.log(`${result.document.title}: ${result.score}`);
}Hybrid Search (Text + Vector)
const queryVector = await getEmbedding("useful tool");
const results = await searchClient.search("tool", {
vectorSearchOptions: {
queries: [
{
kind: "vector",
vector: queryVector,
fields: ["embedding"],
kNearestNeighborsCount: 50,
},
],
},
select: ["id", "title", "description"],
top: 10,
});Semantic Search
// Index must have semantic configuration
const index: SearchIndex = {
name: "products",
fields: [...],
semanticSearch: {
configurations: [
{
name: "semantic-config",
prioritizedFields: {
titleField: { name: "title" },
contentFields: [{ name: "description" }],
},
},
],
},
};
// Search with semantic ranking
const results = await searchClient.search("best tool for the job", {
queryType: "semantic",
semanticSearchOptions: {
configurationName: "semantic-config",
captions: { captionType: "extractive" },
answers: { answerType: "extractive", count: 3 },
},
select: ["id", "title", "description"],
});
for await (const result of results.results) {
console.log(`${result.document.title}`);
console.log(` Caption: ${result.captions?.[0]?.text}`);
console.log(` Reranker Score: ${result.rerankerScore}`);
}Filtering and Facets
// Filter syntax
const results = await searchClient.search("*", {
filter: "category eq 'Electronics' and price lt 100",
facets: ["category,count:10", "brand"],
});
// Access facets
for (const [facetName, facetResults] of Object.entries(results.facets || {})) {
console.log(`${facetName}:`);
for (const facet of facetResults) {
console.log(` ${facet.value}: ${facet.count}`);
}
}Autocomplete and Suggestions
// Create suggester in index
const index: SearchIndex = {
name: "products",
fields: [...],
suggesters: [
{ name: "sg", sourceFields: ["title", "description"] },
],
};
// Autocomplete
const autocomplete = await searchClient.autocomplete("wid", "sg", {
mode: "twoTerms",
top: 5,
});
// Suggestions
const suggestions = await searchClient.suggest("wid", "sg", {
select: ["title"],
top: 5,
});Batch Operations
// Batch upload, merge, delete
const batch = [
{ upload: { id: "1", title: "New Item" } },
{ merge: { id: "2", title: "Updated Title" } },
{ delete: { id: "3" } },
];
const result = await searchClient.indexDocuments({ actions: batch });Key Types
import {
SearchClient,
SearchIndexClient,
SearchIndexerClient,
SearchIndex,
SearchField,
SearchOptions,
VectorSearch,
SemanticSearch,
SearchIterator,
} from "@azure/search-documents";Best Practices
1. Use hybrid search - Combine vector + text for best results
2. Enable semantic ranking - Improves relevance for natural language queries
3. Batch document uploads - Use uploadDocuments with arrays, not single docs
4. Use filters for security - Implement document-level security with filters
5. Index incrementally - Use mergeOrUploadDocuments for updates
6. Monitor query performance - Use includeTotalCount: true sparingly in production
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Related skills
- azure-security-keyvault-keys-dotnet – Azure Key Vault Keys SDK for .NET. Client library for managing cryptographic keys in…
- azure-servicebus-dotnet – Azure Service Bus SDK for .NET. Enterprise messaging with queues, topics, subscriptions…
- azure-servicebus-py – Azure Service Bus SDK for Python messaging. Use for queues, topics, subscriptions, and…
- azure-servicebus-ts – Enterprise messaging with queues, topics, and subscriptions.
- azure-speech-to-text-rest-py – Azure Speech to Text REST API for short audio (Python). Use for simple speech…
- azure-sql – Provision Azure SQL Database and Cosmos DB. Configure security, backups, and…
- docker-development – Docker and container development agent skill and plugin for Dockerfile optimization…
- azure-storage-blob-py – Azure Blob Storage SDK for Python. Use for uploading, downloading, listing blobs…