Azure 认知搜索的 Python 代码示例Python code samples for Azure Cognitive Search

了解演示 Azure 认知搜索的特性和功能的 Python 代码示例。Learn about the Python code samples that demonstrate the features and functionality of Azure Cognitive Search. 主存储库如下所示:The primary repositories are as follows:

存储库Repository 说明Description
azure-sdk-for-python/tree/master/sdk/search/azure-search-documents/samples/azure-sdk-for-python/tree/master/sdk/search/azure-search-documents/samples/ SDK 中 Azure.Search.Documents 客户端库附带的由 Azure SDK 团队生成的示例。Samples produced by the Azure SDK team that ship with the Azure.Search.Documents client library in the SDK. 你还可以查看客户端库的单元测试,以了解如何调用各种 API。You can also review unit tests for the client library to see how various APIs are called.
Azure-Samples/azure-search-python-samplesAzure-Samples/azure-search-python-samples 操作方法文章附带的代码示例,包括快速入门:使用 Python 创建搜索索引Code samples that accompany how-to articles, including Quickstart: Create a search index in Python.


请尝试使用示例浏览器来搜索 Github 中的 Microsoft 代码示例,搜索时可按产品、服务和语言进行筛选。Try the Samples browser to search for Microsoft code samples in Github, filtered by product, service, and language.

Python SDK 示例Python SDK samples

适用于 Python 的 Azure SDK 包含大量示例和一个介绍了先决条件和包安装的入门页面The Azure SDK for Python includes numerous samples and a getting started page that includes prerequisites and package installation. 此页面还包含指向以下示例的链接,为方便起见,这些示例在此处列出。The page also contains links to the following samples, listed here for your convenience.

示例Samples 说明Description
身份验证Authenticate 演示如何配置客户端以及向服务进行身份验证。Demonstrates how to configure a client and authenticate to the service.
索引创建-读取-更新-删除操作Index Create-Read-Update-Delete operations 演示如何创建、更新、获取、列出和删除搜索索引Demonstrates how to create, update, get, list, and delete search indexes.
索引器创建-读取-更新-删除操作Indexer Create-Read-Update-Delete operations 演示如何创建、更新、获取、列出、重置和删除索引器Demonstrates how to create, update, get, list, reset, and delete indexers.
搜索索引器数据源Search indexer data sources 演示如何创建、更新、获取、列出和删除索引器数据源,对于基于索引器为支持的 Azure 数据源编制索引而言,这些数据源是必需的。Demonstrates how to create, update, get, list, and delete indexer data sources, required for indexer-based indexing of supported Azure data sources.
同义词Synonyms 演示如何创建、更新、获取、列出和删除同义词映射Demonstrates how to create, update, get, list, and delete synonym maps.
加载文档Load documents 演示如何在数据导入操作中将文档上传或合并到索引中。Demonstrates how to upload or merge documents into an index in a data import operation.
简单查询Simple query 演示如何设置基本查询Demonstrates how to set up a basic query.
筛选器查询Filter query 演示如何设置筛选器表达式Demonstrates setting up a filter expression.
Facet 查询Facet query 演示如何使用 facetDemonstrates working with facets.

文档示例Documentation samples

Azure 认知搜索文档中有与以下示例相关联的文章。The following samples have an associated article in Azure Cognitive Search documentation.

示例Samples 说明Description
快速入门quickstart 快速入门:使用 Python 创建搜索索引的源代码。Source code for Quickstart: Create a search index in Python.
tutorial-ai-enrichmenttutorial-ai-enrichment 教程:使用 Python 和 AI 从 Azure Blob 生成可搜索的内容的源代码。Source code for Tutorial: Use Python and AI to generate searchable content from Azure blobs.
AzureML-Custom-SkillAzureML-Custom-Skill 示例:使用 Python 创建自定义技能的源代码。Source code for Example: Create a custom skill using Python.