Python samples for Azure AI Search
Learn about the Python code samples that demonstrate the functionality and workflow of an Azure AI Search solution. These samples use the Azure AI Search client library for the Azure SDK for Python, which you can explore through the following links.
|API test cases
Code samples from the Azure SDK development team demonstrate API usage. You can find these samples in azure-sdk-for-python/tree/main/sdk/search/azure-search-documents/samples on GitHub.
|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
|Demonstrates how to create, update, get, list, and delete indexer data sources, required for indexer-based indexing of supported Azure data sources.
|Demonstrates how to create, update, get, list, and delete synonym maps.
|Demonstrates how to upload or merge documents into an index in a data import operation.
|Demonstrates how to set up a basic query.
|Demonstrates setting up a filter expression.
|Demonstrates working with facets.
|Semantic ranking sample
|Shows you how to configure semantic ranking in an index and invoke semantic queries.
|Demonstrates how to get embeddings from a description field and then send vector queries against the data.
Code samples from the Azure AI 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-python-samples on GitHub.
|Source code for the Python portion of Quickstart: Full text search using the Azure SDKs. This article covers the basic workflow for creating, loading, and querying a search index using sample data.
|Source code for the Python portion of Quickstart: Semantic ranking using the Azure SDKs. It shows the index schema and query request for invoking semantic ranking.
|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.
|Source code for Tutorial: Use Python and AI to generate searchable content from Azure blobs. This article shows how to create a blob indexer with a cognitive skillset, where the skillset creates and transforms raw content to make it searchable or consumable.
A demo repo provides proof-of-concept source code for examples or scenarios shown in demonstrations. Demo solutions aren't designed for adaptation by customers.
|Uses the azure.search.documents library in the Azure SDK for Python to create, load, and query a vector store.
|Extends the vector store workflow to include integrated data chunking and embedding.
|Demonstrates image embedding.
|Demonstrates image retrieval.
|Hugging Face integration.
|ChatGPT + Enterprise data with Azure OpenAI Python code showing how to use Azure AI Search with the large language models in Azure OpenAI. For background, see this Tech Community blog post: Revolutionize your Enterprise Data with ChatGPT.
The following samples are also published by the Azure AI Search team, but aren't referenced in documentation. Associated readme files provide usage instructions.
|Uses the azure.search.documents library in the Azure SDK for Python to make a local copy of the retrievable fields of a search index, and then push those fields to a new search index.
Try the Samples browser to search for Microsoft code samples in GitHub, filtered by product, service, and language.