[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-0f105813-365b-49a4-a720-957f40c1e7f9":3,"$flay8KUb5jzjYAGfPOkEDwwLJV4yIxKlRnwNKXGaGkzA":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},"0f105813-365b-49a4-a720-957f40c1e7f9","azure-search-documents-py","Azure AI 搜索 SDK for Python。用于向量搜索、混合搜索、语义排序、索引和技能集。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-search-documents-py\ndescription: Azure AI Search SDK for Python. Use for vector search, hybrid search, semantic ranking, indexing, and skillsets.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure AI Search SDK for Python\n\nFull-text, vector, and hybrid search with AI enrichment capabilities.\n\n## Installation\n\n```bash\npip install azure-search-documents\n```\n\n## Environment Variables\n\n```bash\nAZURE_SEARCH_ENDPOINT=https:\u002F\u002F\u003Cservice-name>.search.windows.net\nAZURE_SEARCH_API_KEY=\u003Cyour-api-key>\nAZURE_SEARCH_INDEX_NAME=\u003Cyour-index-name>\n```\n\n## Authentication\n\n### API Key\n\n```python\nfrom azure.search.documents import SearchClient\nfrom azure.core.credentials import AzureKeyCredential\n\nclient = SearchClient(\n    endpoint=os.environ[\"AZURE_SEARCH_ENDPOINT\"],\n    index_name=os.environ[\"AZURE_SEARCH_INDEX_NAME\"],\n    credential=AzureKeyCredential(os.environ[\"AZURE_SEARCH_API_KEY\"])\n)\n```\n\n### Entra ID (Recommended)\n\n```python\nfrom azure.search.documents import SearchClient\nfrom azure.identity import DefaultAzureCredential\n\nclient = SearchClient(\n    endpoint=os.environ[\"AZURE_SEARCH_ENDPOINT\"],\n    index_name=os.environ[\"AZURE_SEARCH_INDEX_NAME\"],\n    credential=DefaultAzureCredential()\n)\n```\n\n## Client Types\n\n| Client | Purpose |\n|--------|---------|\n| `SearchClient` | Search and document operations |\n| `SearchIndexClient` | Index management, synonym maps |\n| `SearchIndexerClient` | Indexers, data sources, skillsets |\n\n## Create Index with Vector Field\n\n```python\nfrom azure.search.documents.indexes import SearchIndexClient\nfrom azure.search.documents.indexes.models import (\n    SearchIndex,\n    SearchField,\n    SearchFieldDataType,\n    VectorSearch,\n    HnswAlgorithmConfiguration,\n    VectorSearchProfile,\n    SearchableField,\n    SimpleField\n)\n\nindex_client = SearchIndexClient(endpoint, AzureKeyCredential(key))\n\nfields = [\n    SimpleField(name=\"id\", type=SearchFieldDataType.String, key=True),\n    SearchableField(name=\"title\", type=SearchFieldDataType.String),\n    SearchableField(name=\"content\", type=SearchFieldDataType.String),\n    SearchField(\n        name=\"content_vector\",\n        type=SearchFieldDataType.Collection(SearchFieldDataType.Single),\n        searchable=True,\n        vector_search_dimensions=1536,\n        vector_search_profile_name=\"my-vector-profile\"\n    )\n]\n\nvector_search = VectorSearch(\n    algorithms=[\n        HnswAlgorithmConfiguration(name=\"my-hnsw\")\n    ],\n    profiles=[\n        VectorSearchProfile(\n            name=\"my-vector-profile\",\n            algorithm_configuration_name=\"my-hnsw\"\n        )\n    ]\n)\n\nindex = SearchIndex(\n    name=\"my-index\",\n    fields=fields,\n    vector_search=vector_search\n)\n\nindex_client.create_or_update_index(index)\n```\n\n## Upload Documents\n\n```python\nfrom azure.search.documents import SearchClient\n\nclient = SearchClient(endpoint, \"my-index\", AzureKeyCredential(key))\n\ndocuments = [\n    {\n        \"id\": \"1\",\n        \"title\": \"Azure AI Search\",\n        \"content\": \"Full-text and vector search service\",\n        \"content_vector\": [0.1, 0.2, ...]  # 1536 dimensions\n    }\n]\n\nresult = client.upload_documents(documents)\nprint(f\"Uploaded {len(result)} documents\")\n```\n\n## Keyword Search\n\n```python\nresults = client.search(\n    search_text=\"azure search\",\n    select=[\"id\", \"title\", \"content\"],\n    top=10\n)\n\nfor result in results:\n    print(f\"{result['title']}: {result['@search.score']}\")\n```\n\n## Vector Search\n\n```python\nfrom azure.search.documents.models import VectorizedQuery\n\n# Your query embedding (1536 dimensions)\nquery_vector = get_embedding(\"semantic search capabilities\")\n\nvector_query = VectorizedQuery(\n    vector=query_vector,\n    k_nearest_neighbors=10,\n    fields=\"content_vector\"\n)\n\nresults = client.search(\n    vector_queries=[vector_query],\n    select=[\"id\", \"title\", \"content\"]\n)\n\nfor result in results:\n    print(f\"{result['title']}: {result['@search.score']}\")\n```\n\n## Hybrid Search (Vector + Keyword)\n\n```python\nfrom azure.search.documents.models import VectorizedQuery\n\nvector_query = VectorizedQuery(\n    vector=query_vector,\n    k_nearest_neighbors=10,\n    fields=\"content_vector\"\n)\n\nresults = client.search(\n    search_text=\"azure search\",\n    vector_queries=[vector_query],\n    select=[\"id\", \"title\", \"content\"],\n    top=10\n)\n```\n\n## Semantic Ranking\n\n```python\nfrom azure.search.documents.models import QueryType\n\nresults = client.search(\n    search_text=\"what is azure search\",\n    query_type=QueryType.SEMANTIC,\n    semantic_configuration_name=\"my-semantic-config\",\n    select=[\"id\", \"title\", \"content\"],\n    top=10\n)\n\nfor result in results:\n    print(f\"{result['title']}\")\n    if result.get(\"@search.captions\"):\n        print(f\"  Caption: {result['@search.captions'][0].text}\")\n```\n\n## Filters\n\n```python\nresults = client.search(\n    search_text=\"*\",\n    filter=\"category eq 'Technology' and rating gt 4\",\n    order_by=[\"rating desc\"],\n    select=[\"id\", \"title\", \"category\", \"rating\"]\n)\n```\n\n## Facets\n\n```python\nresults = client.search(\n    search_text=\"*\",\n    facets=[\"category,count:10\", \"rating\"],\n    top=0  # Only get facets, no documents\n)\n\nfor facet_name, facet_values in results.get_facets().items():\n    print(f\"{facet_name}:\")\n    for facet in facet_values:\n        print(f\"  {facet['value']}: {facet['count']}\")\n```\n\n## Autocomplete & Suggest\n\n```python\n# Autocomplete\nresults = client.autocomplete(\n    search_text=\"sea\",\n    suggester_name=\"my-suggester\",\n    mode=\"twoTerms\"\n)\n\n# Suggest\nresults = client.suggest(\n    search_text=\"sea\",\n    suggester_name=\"my-suggester\",\n    select=[\"title\"]\n)\n```\n\n## Indexer with Skillset\n\n```python\nfrom azure.search.documents.indexes import SearchIndexerClient\nfrom azure.search.documents.indexes.models import (\n    SearchIndexer,\n    SearchIndexerDataSourceConnection,\n    SearchIndexerSkillset,\n    EntityRecognitionSkill,\n    InputFieldMappingEntry,\n    OutputFieldMappingEntry\n)\n\nindexer_client = SearchIndexerClient(endpoint, AzureKeyCredential(key))\n\n# Create data source\ndata_source = SearchIndexerDataSourceConnection(\n    name=\"my-datasource\",\n    type=\"azureblob\",\n    connection_string=connection_string,\n    container={\"name\": \"documents\"}\n)\nindexer_client.create_or_update_data_source_connection(data_source)\n\n# Create skillset\nskillset = SearchIndexerSkillset(\n    name=\"my-skillset\",\n    skills=[\n        EntityRecognitionSkill(\n            inputs=[InputFieldMappingEntry(name=\"text\", source=\"\u002Fdocument\u002Fcontent\")],\n            outputs=[OutputFieldMappingEntry(name=\"organizations\", target_name=\"organizations\")]\n        )\n    ]\n)\nindexer_client.create_or_update_skillset(skillset)\n\n# Create indexer\nindexer = SearchIndexer(\n    name=\"my-indexer\",\n    data_source_name=\"my-datasource\",\n    target_index_name=\"my-index\",\n    skillset_name=\"my-skillset\"\n)\nindexer_client.create_or_update_indexer(indexer)\n```\n\n## Best Practices\n\n1. **Use hybrid search** for best relevance combining vector and keyword\n2. **Enable semantic ranking** for natural language queries\n3. **Index in batches** of 100-1000 documents for efficiency\n4. **Use filters** to narrow results before ranking\n5. **Configure vector dimensions** to match your embedding model\n6. **Use HNSW algorithm** for large-scale vector search\n7. **Create suggesters** at index creation time (cannot add later)\n\n## Reference Files\n\n| File | Contents |\n|------|----------|\n| references\u002Fvector-search.md | HNSW configuration, integrated vectorization, multi-vector queries |\n| references\u002Fsemantic-ranking.md | Semantic configuration, captions, answers, hybrid patterns |\n| scripts\u002Fsetup_vector_index.py | CLI script to create vector-enabled search index |\n\n\n---\n\n## Additional Azure AI Search Patterns\n\n### Additional SDK Focus\n\nWrite clean, idiomatic Python code for Azure AI Search using `azure-search-documents`.\n\n## Installation for Additional Patterns\n\n```bash\npip install azure-search-documents azure-identity\n```\n\n## Environment Variables for Additional Patterns\n\n```bash\nAZURE_SEARCH_ENDPOINT=https:\u002F\u002F\u003Csearch-service>.search.windows.net\nAZURE_SEARCH_INDEX_NAME=\u003Cindex-name>\n# For API key auth (not recommended for production)\nAZURE_SEARCH_API_KEY=\u003Capi-key>\n```\n\n## Authentication for Additional Patterns\n\n**DefaultAzureCredential (preferred)**:\n```python\nfrom azure.identity import DefaultAzureCredential\nfrom azure.search.documents import SearchClient\n\ncredential = DefaultAzureCredential()\nclient = SearchClient(endpoint, index_name, credential)\n```\n\n**API Key**:\n```python\nfrom azure.core.credentials import AzureKeyCredential\nfrom azure.search.documents import SearchClient\n\nclient = SearchClient(endpoint, index_name, AzureKeyCredential(api_key))\n```\n\n## Client Selection\n\n| Client | Purpose |\n|--------|---------|\n| `SearchClient` | Query indexes, upload\u002Fupdate\u002Fdelete documents |\n| `SearchIndexClient` | Create\u002Fmanage indexes, knowledge sources, knowledge bases |\n| `SearchIndexerClient` | Manage indexers, skillsets, data sources |\n| `KnowledgeBaseRetrievalClient` | Agentic retrieval with LLM-powered Q&A |\n\n## Index Creation Pattern\n\n```python\nfrom azure.search.documents.indexes import SearchIndexClient\nfrom azure.search.documents.indexes.models import (\n    SearchIndex, SearchField, VectorSearch, VectorSearchProfile,\n    HnswAlgorithmConfiguration, AzureOpenAIVectorizer,\n    AzureOpenAIVectorizerParameters, SemanticSearch,\n    SemanticConfiguration, SemanticPrioritizedFields, SemanticField\n)\n\nindex = SearchIndex(\n    name=index_name,\n    fields=[\n        SearchField(name=\"id\", type=\"Edm.String\", key=True),\n        SearchField(name=\"content\", type=\"Edm.String\", searchable=True),\n        SearchField(name=\"embedding\", type=\"Collection(Edm.Single)\",\n                   vector_search_dimensions=3072,\n                   vector_search_profile_name=\"vector-profile\"),\n    ],\n    vector_search=VectorSearch(\n        profiles=[VectorSearchProfile(\n            name=\"vector-profile\",\n            algorithm_configuration_name=\"hnsw-algo\",\n            vectorizer_name=\"openai-vectorizer\"\n        )],\n        algorithms=[HnswAlgorithmConfiguration(name=\"hnsw-algo\")],\n        vectorizers=[AzureOpenAIVectorizer(\n            vectorizer_name=\"openai-vectorizer\",\n            parameters=AzureOpenAIVectorizerParameters(\n                resource_url=aoai_endpoint,\n                deployment_name=embedding_deployment,\n                model_name=embedding_model\n            )\n        )]\n    ),\n    semantic_search=SemanticSearch(\n        default_configuration_name=\"semantic-config\",\n        configurations=[SemanticConfiguration(\n            name=\"semantic-config\",\n            prioritized_fields=SemanticPrioritizedFields(\n                content_fields=[SemanticField(field_name=\"content\")]\n            )\n        )]\n    )\n)\n\nindex_client = SearchIndexClient(endpoint, credential)\nindex_client.create_or_update_index(index)\n```\n\n## Document Operations\n\n```python\nfrom azure.search.documents import SearchIndexingBufferedSender\n\n# Batch upload with automatic batching\nwith SearchIndexingBufferedSender(endpoint, index_name, credential) as sender:\n    sender.upload_documents(documents)\n\n# Direct operations via SearchClient\nsearch_client = SearchClient(endpoint, index_name, credential)\nsearch_client.upload_documents(documents)      # Add new\nsearch_client.merge_documents(documents)       # Update existing\nsearch_client.merge_or_upload_documents(documents)  # Upsert\nsearch_client.delete_documents(documents)      # Remove\n```\n\n## Search Patterns\n\n```python\n# Basic search\nresults = search_client.search(search_text=\"query\")\n\n# Vector search\nfrom azure.search.documents.models import VectorizedQuery\n\nresults = search_client.search(\n    search_text=None,\n    vector_queries=[VectorizedQuery(\n        vector=embedding,\n        k_nearest_neighbors=5,\n        fields=\"embedding\"\n    )]\n)\n\n# Hybrid search (vector + keyword)\nresults = search_client.search(\n    search_text=\"query\",\n    vector_queries=[VectorizedQuery(vector=embedding, k_nearest_neighbors=5, fields=\"embedding\")],\n    query_type=\"semantic\",\n    semantic_configuration_name=\"semantic-config\"\n)\n\n# With filters\nresults = search_client.search(\n    search_text=\"query\",\n    filter=\"category eq 'technology'\",\n    select=[\"id\", \"title\", \"content\"],\n    top=10\n)\n```\n\n## Agentic Retrieval (Knowledge Bases)\n\nFor LLM-powered Q&A with answer synthesis, see references\u002Fagentic-retrieval.md.\n\nKey concepts:\n- **Knowledge Source**: Points to a search index\n- **Knowledge Base**: Wraps knowledge sources + LLM for query planning and synthesis\n- **Output modes**: `EXTRACTIVE_DATA` (raw chunks) or `ANSWER_SYNTHESIS` (LLM-generated answers)\n\n## Async Pattern\n\n```python\nfrom azure.search.documents.aio import SearchClient\n\nasync with SearchClient(endpoint, index_name, credential) as client:\n    results = await client.search(search_text=\"query\")\n    async for result in results:\n        print(result[\"title\"])\n```\n\n## Best Practices for Additional Patterns\n\n1. **Use environment variables** for endpoints, keys, and deployment names\n2. **Prefer `DefaultAzureCredential`** over API keys for production\n3. **Use `SearchIndexingBufferedSender`** for batch uploads (handles batching\u002Fretries)\n4. **Always define semantic configuration** for agentic retrieval indexes\n5. **Use `create_or_update_index`** for idempotent index creation\n6. **Close clients** with context managers or explicit `close()`\n\n## Field Types Reference\n\n| EDM Type | Python | Notes |\n|----------|--------|-------|\n| `Edm.String` | str | Searchable text |\n| `Edm.Int32` | int | Integer |\n| `Edm.Int64` | int | Long integer |\n| `Edm.Double` | float | Floating point |\n| `Edm.Boolean` | bool | True\u002FFalse |\n| `Edm.DateTimeOffset` | datetime | ISO 8601 |\n| `Collection(Edm.Single)` | List[float] | Vector embeddings |\n| `Collection(Edm.String)` | List[str] | String arrays |\n\n## Error Handling\n\n```python\nfrom azure.core.exceptions import (\n    HttpResponseError,\n    ResourceNotFoundError,\n    ResourceExistsError\n)\n\ntry:\n    result = search_client.get_document(key=\"123\")\nexcept ResourceNotFoundError:\n    print(\"Document not found\")\nexcept HttpResponseError as e:\n    print(f\"Search error: {e.message}\")\n```\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,64,1410,"2026-05-16 13:07:32",{"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},"5ecc1dcf-368e-42ed-be4f-edde4f51df0b","1.0.0","azure-search-documents-py.zip",4247,"uploads\u002Fskills\u002F0f105813-365b-49a4-a720-957f40c1e7f9\u002Fazure-search-documents-py.zip","78ecbde54579fd62b01380d8e802321e951387a2e7f8f2afdfb75e7251a65a91","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":14527}]",{"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]