Azure Cognitive Services Search SDK
Leverage the power of Azure Cognitive Services Search through our robust and easy-to-use Software Development Kits (SDKs). Integrate intelligent search capabilities directly into your applications.
Supported SDKs
We provide SDKs for popular programming languages to simplify integration with Azure Cognitive Services Search.
Python SDK
The Python SDK offers a comprehensive set of tools for interacting with Azure Cognitive Services Search. It's designed for ease of use and efficient data handling.
Installation:
pip install azure-search-documents
Example Usage:
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
# Replace with your actual service name, API key, and index name
service_name = "YOUR_SEARCH_SERVICE_NAME"
key = "YOUR_SEARCH_API_KEY"
index_name = "YOUR_INDEX_NAME"
endpoint = f"https://{service_name}.search.windows.net"
credential = AzureKeyCredential(key)
search_client = SearchClient(endpoint, index_name, credential)
# Perform a search query
results = search_client.search(
search_text="sample query",
# filter="category eq 'electronics'",
# select="id,name,description"
)
print("Search Results:")
for result in results:
print(f" - {result['name']} (Score: {result['@search.score']})")
View Python SDK Details
GitHub Repository
.NET SDK
For .NET developers, our SDK provides seamless integration for building powerful search experiences within your applications.
Installation (NuGet):
Install-Package Azure.Search.Documents
Example Usage:
using Azure;
using Azure.Search.Documents;
using Azure.Search.Documents.Models;
using System;
using System.Threading.Tasks;
public class SearchExample
{
public static async Task Main(string[] args)
{
string serviceName = "YOUR_SEARCH_SERVICE_NAME";
string apiKey = "YOUR_SEARCH_API_KEY";
string indexName = "YOUR_INDEX_NAME";
Uri endpoint = new Uri($"https://{serviceName}.search.windows.net");
AzureKeyCredential credential = new AzureKeyCredential(apiKey);
SearchClient searchClient = new SearchClient(endpoint, indexName, credential);
Console.WriteLine($"Searching for 'sample query' in index '{indexName}':");
Response> response = await searchClient.SearchAsync("sample query");
foreach (SearchResult result in response.Value.GetResultItems())
{
Console.WriteLine($" - {result.Document["name"]} (Score: {result.Score})");
}
}
}
View .NET SDK Details
GitHub Repository
Java SDK
Integrate Azure Cognitive Services Search into your Java applications with our comprehensive SDK.
Maven Dependency:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-search-documents</artifactId>
<version>VERSION_HERE</version>
</dependency>
Example Usage:
import com.azure.core.credential.AzureKeyCredential;
import com.azure.search.documents.SearchClient;
import com.azure.search.documents.SearchClientBuilder;
import com.azure.search.documents.models.SearchDocument;
import com.azure.search.documents.models.SearchResults;
public class SearchSample {
public static void main(String[] args) {
String serviceName = "YOUR_SEARCH_SERVICE_NAME";
String apiKey = "YOUR_SEARCH_API_KEY";
String indexName = "YOUR_INDEX_NAME";
String endpoint = String.format("https://%s.search.windows.net", serviceName);
AzureKeyCredential credential = new AzureKeyCredential(apiKey);
SearchClient searchClient = new SearchClientBuilder()
.endpoint(endpoint)
.indexName(indexName)
.credential(credential)
.buildClient();
System.out.println("Searching for 'sample query':");
SearchResults results = searchClient.search("sample query");
results.getSearchDocuments().forEach(doc ->
System.out.printf(" - %s (Score: %.2f)%n", doc.get("name"), doc.get("@search.score"))
);
}
}
View Java SDK Details
GitHub Repository
Key Features
- Rich Querying: Perform complex searches with filters, faceting, and scoring profiles.
- Document Management: Easily upload, update, and delete documents in your index.
- Autocomplete & Suggestions: Enhance user experience with real-time search suggestions.
- Synonym Maps: Improve search relevance by defining custom synonyms.
- Security: Secure your search service with API keys and Azure Active Directory.
Getting Started
- Create an Azure Cognitive Services Search resource in the Azure portal.
- Create an index to define the schema for your searchable data.
- Install the relevant SDK for your preferred programming language.
- Authenticate using your service endpoint and API key.
- Start querying and indexing your data.
For detailed guidance and advanced scenarios, please refer to the specific SDK documentation linked above.