REST API Examples - Analyzers & Scoring¶
This directory contains REST API examples for Azure AI Search analyzer and scoring profile operations using direct HTTP requests.
Prerequisites¶
- Azure AI Search service (Standard tier or higher)
- Admin API key for index management operations
- Query API key for search operations
- HTTP client (curl, Postman, VS Code REST Client, etc.)
Configuration¶
Update the following variables in each .http file:
@searchServiceName = your-search-service
@adminKey = your-admin-key
@queryKey = your-query-key
@apiVersion = 2024-07-01
Sample Files¶
Core Examples¶
01_builtin_analyzers.http- Built-in analyzer testing and comparison02_custom_analyzers.http- Custom analyzer creation and configuration03_analyzer_testing.http- Comprehensive analyzer testing framework04_ngram_autocomplete.http- N-gram analyzers for autocomplete functionality05_basic_scoring.http- Basic scoring profile implementation and testing06_advanced_scoring.http- Complex scoring with multiple functions07_location_scoring.http- Geographic distance-based scoring profiles08_performance_optimization.http- Performance testing and optimizationanalyze_api_examples.http- Comprehensive Analyze API usage examplesindex_management.http- Index creation and management operations
Using the Examples¶
VS Code REST Client¶
- Install the REST Client extension
- Open any
.httpfile - Update the configuration variables
- Click "Send Request" above each HTTP request
curl Commands¶
Copy the HTTP requests and convert to curl format:
curl -X POST "https://your-service.search.windows.net/indexes/test-index/analyze?api-version=2024-07-01" \
-H "Content-Type: application/json" \
-H "api-key: your-admin-key" \
-d '{"text": "sample text", "analyzer": "standard.lucene"}'
Postman¶
- Import the HTTP requests into Postman
- Set up environment variables for service name and keys
- Execute requests individually or as collections
Features Demonstrated¶
- Index Management: Create, update, and delete indexes with custom analyzers
- Analyze API: Test text processing with different analyzers and components
- Document Operations: Upload, update, and delete documents
- Search Operations: Query with different scoring profiles and parameters
- Performance Testing: Measure response times and throughput
- Error Handling: Handle common API errors and responses
API Endpoints Covered¶
Index Management¶
POST /indexes- Create index with analyzers and scoring profilesPUT /indexes/{indexName}- Update existing indexGET /indexes/{indexName}- Retrieve index definitionDELETE /indexes/{indexName}- Delete index
Text Analysis¶
POST /indexes/{indexName}/analyze- Analyze text with specified analyzerPOST /indexes/{indexName}/analyze- Test custom analyzer components
Document Operations¶
POST /indexes/{indexName}/docs/index- Upload documentsPOST /indexes/{indexName}/docs/search- Search documentsGET /indexes/{indexName}/docs/{key}- Retrieve specific document
Service Operations¶
GET /servicestats- Get service statistics and usageGET /indexes- List all indexes in the service
Best Practices Demonstrated¶
- Proper API key usage and security
- Efficient batch operations for document management
- Error handling and response validation
- Performance optimization techniques
- Monitoring and logging patterns