[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-dc2ff90c-c51e-4dae-abfa-20fdc32f5e88":3,"$fahH56wJvtWbyO0ZG6UQ0ESvg9sjCZEbd44Udalx86Lw":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"dc2ff90c-c51e-4dae-abfa-20fdc32f5e88","azure-search-documents-ts","构建具有向量、混合和语义搜索功能的搜索应用程序。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-search-documents-ts\ndescription: \"Build search applications with vector, hybrid, and semantic search capabilities.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Azure AI Search SDK for TypeScript\n\nBuild search applications with vector, hybrid, and semantic search capabilities.\n\n## Installation\n\n```bash\nnpm install @azure\u002Fsearch-documents @azure\u002Fidentity\n```\n\n## Environment Variables\n\n```bash\nAZURE_SEARCH_ENDPOINT=https:\u002F\u002F\u003Cservice-name>.search.windows.net\nAZURE_SEARCH_INDEX_NAME=my-index\nAZURE_SEARCH_ADMIN_KEY=\u003Cadmin-key>  # Optional if using Entra ID\n```\n\n## Authentication\n\n```typescript\nimport { SearchClient, SearchIndexClient } from \"@azure\u002Fsearch-documents\";\nimport { DefaultAzureCredential } from \"@azure\u002Fidentity\";\n\nconst endpoint = process.env.AZURE_SEARCH_ENDPOINT!;\nconst indexName = process.env.AZURE_SEARCH_INDEX_NAME!;\nconst credential = new DefaultAzureCredential();\n\n\u002F\u002F For searching\nconst searchClient = new SearchClient(endpoint, indexName, credential);\n\n\u002F\u002F For index management\nconst indexClient = new SearchIndexClient(endpoint, credential);\n```\n\n## Core Workflow\n\n### Create Index with Vector Field\n\n```typescript\nimport { SearchIndex, SearchField, VectorSearch } from \"@azure\u002Fsearch-documents\";\n\nconst index: SearchIndex = {\n  name: \"products\",\n  fields: [\n    { name: \"id\", type: \"Edm.String\", key: true },\n    { name: \"title\", type: \"Edm.String\", searchable: true },\n    { name: \"description\", type: \"Edm.String\", searchable: true },\n    { name: \"category\", type: \"Edm.String\", filterable: true, facetable: true },\n    {\n      name: \"embedding\",\n      type: \"Collection(Edm.Single)\",\n      searchable: true,\n      vectorSearchDimensions: 1536,\n      vectorSearchProfileName: \"vector-profile\",\n    },\n  ],\n  vectorSearch: {\n    algorithms: [\n      { name: \"hnsw-algorithm\", kind: \"hnsw\" },\n    ],\n    profiles: [\n      { name: \"vector-profile\", algorithmConfigurationName: \"hnsw-algorithm\" },\n    ],\n  },\n};\n\nawait indexClient.createOrUpdateIndex(index);\n```\n\n### Index Documents\n\n```typescript\nconst documents = [\n  { id: \"1\", title: \"Widget\", description: \"A useful widget\", category: \"Tools\", embedding: [...] },\n  { id: \"2\", title: \"Gadget\", description: \"A cool gadget\", category: \"Electronics\", embedding: [...] },\n];\n\nconst result = await searchClient.uploadDocuments(documents);\nconsole.log(`Indexed ${result.results.length} documents`);\n```\n\n### Full-Text Search\n\n```typescript\nconst results = await searchClient.search(\"widget\", {\n  select: [\"id\", \"title\", \"description\"],\n  filter: \"category eq 'Tools'\",\n  orderBy: [\"title asc\"],\n  top: 10,\n});\n\nfor await (const result of results.results) {\n  console.log(`${result.document.title}: ${result.score}`);\n}\n```\n\n### Vector Search\n\n```typescript\nconst queryVector = await getEmbedding(\"useful tool\"); \u002F\u002F Your embedding function\n\nconst results = await searchClient.search(\"*\", {\n  vectorSearchOptions: {\n    queries: [\n      {\n        kind: \"vector\",\n        vector: queryVector,\n        fields: [\"embedding\"],\n        kNearestNeighborsCount: 10,\n      },\n    ],\n  },\n  select: [\"id\", \"title\", \"description\"],\n});\n\nfor await (const result of results.results) {\n  console.log(`${result.document.title}: ${result.score}`);\n}\n```\n\n### Hybrid Search (Text + Vector)\n\n```typescript\nconst queryVector = await getEmbedding(\"useful tool\");\n\nconst results = await searchClient.search(\"tool\", {\n  vectorSearchOptions: {\n    queries: [\n      {\n        kind: \"vector\",\n        vector: queryVector,\n        fields: [\"embedding\"],\n        kNearestNeighborsCount: 50,\n      },\n    ],\n  },\n  select: [\"id\", \"title\", \"description\"],\n  top: 10,\n});\n```\n\n### Semantic Search\n\n```typescript\n\u002F\u002F Index must have semantic configuration\nconst index: SearchIndex = {\n  name: \"products\",\n  fields: [...],\n  semanticSearch: {\n    configurations: [\n      {\n        name: \"semantic-config\",\n        prioritizedFields: {\n          titleField: { name: \"title\" },\n          contentFields: [{ name: \"description\" }],\n        },\n      },\n    ],\n  },\n};\n\n\u002F\u002F Search with semantic ranking\nconst results = await searchClient.search(\"best tool for the job\", {\n  queryType: \"semantic\",\n  semanticSearchOptions: {\n    configurationName: \"semantic-config\",\n    captions: { captionType: \"extractive\" },\n    answers: { answerType: \"extractive\", count: 3 },\n  },\n  select: [\"id\", \"title\", \"description\"],\n});\n\nfor await (const result of results.results) {\n  console.log(`${result.document.title}`);\n  console.log(`  Caption: ${result.captions?.[0]?.text}`);\n  console.log(`  Reranker Score: ${result.rerankerScore}`);\n}\n```\n\n## Filtering and Facets\n\n```typescript\n\u002F\u002F Filter syntax\nconst results = await searchClient.search(\"*\", {\n  filter: \"category eq 'Electronics' and price lt 100\",\n  facets: [\"category,count:10\", \"brand\"],\n});\n\n\u002F\u002F Access facets\nfor (const [facetName, facetResults] of Object.entries(results.facets || {})) {\n  console.log(`${facetName}:`);\n  for (const facet of facetResults) {\n    console.log(`  ${facet.value}: ${facet.count}`);\n  }\n}\n```\n\n## Autocomplete and Suggestions\n\n```typescript\n\u002F\u002F Create suggester in index\nconst index: SearchIndex = {\n  name: \"products\",\n  fields: [...],\n  suggesters: [\n    { name: \"sg\", sourceFields: [\"title\", \"description\"] },\n  ],\n};\n\n\u002F\u002F Autocomplete\nconst autocomplete = await searchClient.autocomplete(\"wid\", \"sg\", {\n  mode: \"twoTerms\",\n  top: 5,\n});\n\n\u002F\u002F Suggestions\nconst suggestions = await searchClient.suggest(\"wid\", \"sg\", {\n  select: [\"title\"],\n  top: 5,\n});\n```\n\n## Batch Operations\n\n```typescript\n\u002F\u002F Batch upload, merge, delete\nconst batch = [\n  { upload: { id: \"1\", title: \"New Item\" } },\n  { merge: { id: \"2\", title: \"Updated Title\" } },\n  { delete: { id: \"3\" } },\n];\n\nconst result = await searchClient.indexDocuments({ actions: batch });\n```\n\n## Key Types\n\n```typescript\nimport {\n  SearchClient,\n  SearchIndexClient,\n  SearchIndexerClient,\n  SearchIndex,\n  SearchField,\n  SearchOptions,\n  VectorSearch,\n  SemanticSearch,\n  SearchIterator,\n} from \"@azure\u002Fsearch-documents\";\n```\n\n## Best Practices\n\n1. **Use hybrid search** - Combine vector + text for best results\n2. **Enable semantic ranking** - Improves relevance for natural language queries\n3. **Batch document uploads** - Use `uploadDocuments` with arrays, not single docs\n4. **Use filters for security** - Implement document-level security with filters\n5. **Index incrementally** - Use `mergeOrUploadDocuments` for updates\n6. **Monitor query performance** - Use `includeTotalCount: true` sparingly in production\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,167,340,"2026-05-16 13:07:33",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"a8b53164-2555-4ce6-9a07-ddb43f28f560","1.0.0","azure-search-documents-ts.zip",2413,"uploads\u002Fskills\u002Fdc2ff90c-c51e-4dae-abfa-20fdc32f5e88\u002Fazure-search-documents-ts.zip","5f8d549c4ed91befced8e719b667be433992de4a36e8c22e3376619595201f59","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":6932}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]