Registry / azure / azure-search

azure-search

JSON →
library1.0.0b2pypypiunverified

The `azure-search` library (version 1.0.0b2, currently in preview) provides a client for interacting with Azure AI Search (formerly Azure Cognitive Search). It's designed for newer API versions and capabilities, distinct from the stable `azure-search-documents` library. As a preview package, it is in active development with rapid changes and is not recommended for production use. Microsoft generally releases updates to its Python SDK packages on a monthly cadence.

pip install azure-search==1.0.0b2
INSTALL
IMPORT
SIG · AZURE-SEARCH
A
azure-search
azurepythonv1.0.0b2
Install
2.7s avg
Import
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0b2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.1MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 2.7s · import 0.000s · 27MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SearchClient
from azure.search.documents import SearchClient
from azure.search.documents import SearchClient

This quickstart demonstrates how to initialize the `SearchIndexClient` to create an index, then use `SearchClient` to upload documents and perform a basic search, and finally clean up by deleting the index. Ensure you have `SEARCH_SERVICE_ENDPOINT` (e.g., `https://<your-service-name>.search.windows.net`) and `SEARCH_ADMIN_KEY` environment variables set with your Azure AI Search service details.

import os from azure.core.credentials import AzureKeyCredential from azure.search.documents import SearchClient from azure.search.documents.indexes import SearchIndexClient from azure.search.documents.models import SearchableField, SearchFieldDataType, SimpleField, SearchIndex # Replace with your Azure AI Search service endpoint and admin key service_endpoint = os.environ.get("SEARCH_SERVICE_ENDPOINT", "https://YOUR_SEARCH_SERVICE_NAME.search.windows.net") admin_key = os.environ.get("SEARCH_ADMIN_KEY", "YOUR_ADMIN_KEY") index_name = "test-index" if not service_endpoint or not admin_key: print("Please set the SEARCH_SERVICE_ENDPOINT and SEARCH_ADMIN_KEY environment variables.") exit(1) # Create a SearchIndexClient credential = AzureKeyCredential(admin_key) index_client = SearchIndexClient(endpoint=service_endpoint, credential=credential) # Define a search index fields = [ SimpleField(name="id", type=SearchFieldDataType.String, key=True), SearchableField(name="title", type=SearchFieldDataType.String, searchable=True), SearchableField(name="description", type=SearchFieldDataType.String, searchable=True), ] index = SearchIndex(name=index_name, fields=fields) # Create the index try: print(f"Creating index '{index_name}'...") index_client.create_index(index) print("Index created.") # Get a SearchClient to add and search documents search_client = SearchClient(endpoint=service_endpoint, index_name=index_name, credential=credential) # Add documents documents = [ {"id": "1", "title": "Azure AI Search Document 1", "description": "This is the first document."}, {"id": "2", "title": "Azure AI Search Document 2", "description": "This is the second document."} ] print(f"Uploading {len(documents)} documents...") search_client.upload_documents(documents) print("Documents uploaded.") # Search documents print("Searching for 'first'...") results = search_client.search(search_text="first") for result in results: print(f"Found document: {result['title']}") finally: # Clean up (delete index) print(f"Deleting index '{index_name}'...") index_client.delete_index(index_name) print("Index deleted.")
Debug
Known issues
breakingThe `azure-search` library is currently in a preview (beta) state. APIs, models, and functionalities are subject to change without backward compatibility before a stable release. It is not recommended for production environments.
fix
For stable production use, consider `azure-search-documents` (version 11.x.x) if its features meet your requirements. Otherwise, frequently check release notes for breaking changes and pin to specific beta versions.
affects: 1.0.0bX
gotchaThe package name is `azure-search`, but the main client classes are imported from the `azure.search.documents` namespace (e.g., `from azure.search.documents import SearchClient`). This can be a source of confusion.
fix
Always refer to the official documentation or quickstart examples for correct import paths. Do not assume the import path matches the package name directly.
affects: 1.0.0bX
gotchaThis `azure-search` preview package is distinct from the stable `azure-search-documents` library. While they interact with the same Azure AI Search service, their APIs, features, and target REST API versions may differ.
fix
Understand which library you intend to use. If you need a stable, production-ready client, use `azure-search-documents`. If you are experimenting with new features or preview API versions, use `azure-search`.
affects: 1.0.0bX
gotchaAzure AI Search clients often target a specific REST API version. Mismatches between the client library's default API version and the API version expected by your Azure AI Search service instance can lead to errors.
fix
Ensure your client library version is compatible with your Azure AI Search service's API version. If encountering `HttpResponseError` with API version messages, consult the service documentation or try explicitly specifying the `api_version` parameter during client instantiation if supported by your client version.
affects: All
Upgrade
Version history
1.0.0b2latest on PyPI · released Jan 22, 2021
Audit
Dependencies
azure-corerequiredCore Azure SDK functionalities like credentials, HTTP pipeline.
Agent activity
83 hits · last 30 days
node
76
Perplexity
1
OpenAI (training)
1
Resources
azure-search — pip install azure-search · libregistry