Skip to content

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 comparison
  • 02_custom_analyzers.http - Custom analyzer creation and configuration
  • 03_analyzer_testing.http - Comprehensive analyzer testing framework
  • 04_ngram_autocomplete.http - N-gram analyzers for autocomplete functionality
  • 05_basic_scoring.http - Basic scoring profile implementation and testing
  • 06_advanced_scoring.http - Complex scoring with multiple functions
  • 07_location_scoring.http - Geographic distance-based scoring profiles
  • 08_performance_optimization.http - Performance testing and optimization
  • analyze_api_examples.http - Comprehensive Analyze API usage examples
  • index_management.http - Index creation and management operations

Using the Examples

VS Code REST Client

  1. Install the REST Client extension
  2. Open any .http file
  3. Update the configuration variables
  4. 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

  1. Import the HTTP requests into Postman
  2. Set up environment variables for service name and keys
  3. 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 profiles
  • PUT /indexes/{indexName} - Update existing index
  • GET /indexes/{indexName} - Retrieve index definition
  • DELETE /indexes/{indexName} - Delete index

Text Analysis

  • POST /indexes/{indexName}/analyze - Analyze text with specified analyzer
  • POST /indexes/{indexName}/analyze - Test custom analyzer components

Document Operations

  • POST /indexes/{indexName}/docs/index - Upload documents
  • POST /indexes/{indexName}/docs/search - Search documents
  • GET /indexes/{indexName}/docs/{key} - Retrieve specific document

Service Operations

  • GET /servicestats - Get service statistics and usage
  • GET /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