Data Sources and Indexers
Complete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks and see fewer ads — read each lesson on a single page with Pro
Understanding Data Sources and Indexers in Azure AI Search
Introduction to Knowledge Mining and Information Extraction
In the modern digital landscape, organizations are flooded with vast quantities of unstructured and semi-structured data. From PDF reports and internal wikis to massive SQL databases and blob storage containers, the challenge is no longer just storing this information, but making it discoverable and useful. This is where the discipline of Knowledge Mining comes into play. Knowledge mining is the process of extracting insights, patterns, and relationships from diverse data sources, effectively turning raw data into an actionable knowledge base.
Azure AI Search acts as the engine for this process. It provides a platform to ingest, index, and query information across your enterprise data. However, before you can search for information, you must bring it into the system. This is where Data Sources and Indexers serve as the foundation of your search architecture. A Data Source defines the connection to your underlying data, while an Indexer acts as the automation layer that crawls that data, extracts content, and maps it into a searchable index. Understanding these two components is essential for anyone building search-driven applications, as they dictate how fresh your data is, how complex your extraction pipelines can be, and how efficiently your system scales.
The Role of Data Sources
A Data Source in Azure AI Search is essentially a configuration object that tells the service where your data lives and how to authenticate with it. It does not store the data itself; rather, it stores the credentials and connection strings required to access the source. By decoupling the connection logic from the search index, Azure allows you to manage security and access controls centrally.
When you configure a data source, you are essentially providing the "map" for the indexer. Depending on the type of data, the configuration parameters vary significantly. For instance, connecting to an Azure SQL Database requires a connection string, a database name, and potentially a specific schema or query to limit the scope of the data. Conversely, connecting to Azure Blob Storage requires a storage account key or a shared access signature (SAS) and the name of the specific container.
Supported Data Sources
Azure AI Search supports a wide range of data sources, which makes it highly flexible for hybrid cloud architectures. The most common sources include:
- Azure SQL Database: Ideal for structured data where you want to map table columns directly to search fields.
- Azure Cosmos DB: Perfect for NoSQL document stores where you need to index JSON documents with nested structures.
- Azure Blob Storage: The standard for unstructured data like PDFs, Word documents, images, and HTML files.
- Azure Data Lake Storage Gen2: Used for large-scale data analytics scenarios where you need to index deep hierarchies of files.
- SharePoint Online: Enables indexing of corporate documents, pages, and lists directly from the Microsoft 365 ecosystem.
Callout: Data Source vs. Indexer - The Critical Distinction It is common for beginners to confuse the data source with the indexer. Think of the Data Source as the "phone book" that contains the address and the password to unlock the door. The Indexer, by contrast, is the "delivery person" who actually walks through the door, picks up the items (documents), checks their contents, and places them on the shelves (the search index). You cannot have an indexer without a data source, but the data source is passive until the indexer starts its work.
The Mechanics of Indexers
An Indexer is a crawler that automates the data ingestion process. It connects to your data source, reads the data, and transforms it based on your defined field mappings. The true power of the indexer lies in its ability to run on a schedule or on-demand, ensuring that your search index stays in sync with your source data without requiring manual intervention.
When an indexer runs, it performs three primary tasks:
- Extraction: It retrieves the data from the source. If the data is in a file format like PDF, the indexer can use built-in document cracking to extract text.
- Transformation: It maps the source data to the target index fields. This is where you can perform data shaping, such as concatenating two fields or converting data types.
- Loading: It pushes the processed data into the Azure AI Search index, making it immediately available for queries.
Setting Up an Indexer: Step-by-Step
To set up an indexer, you generally follow a four-step process: defining the index, creating the data source, creating the indexer, and running it.
Step 1: Define the Index
Before you can crawl data, you need a place to put it. You must define an index schema that outlines the fields, data types, and attributes (like filterable, searchable, or sortable).
Step 2: Create the Data Source
You define the connection details. Using the Azure SDK or REST API, you provide the connection string.
{
"name": "my-sql-datasource",
"type": "azuresql",
"credentials": { "connectionString": "Server=tcp:myserver.database.windows.net..." },
"container": { "name": "my-table" }
}
Step 3: Create the Indexer
The indexer links the data source to the index. You can also specify an "index mapping" here if your source column names do not match your index field names.
{
"name": "my-sql-indexer",
"dataSourceName": "my-sql-datasource",
"targetIndexName": "my-search-index",
"schedule": { "interval": "PT1H" }
}
Step 4: Execute
You can trigger the indexer manually to verify that it works correctly before setting it on a schedule.
Tip: Monitoring and Diagnostics Always check the status of your indexer after the first run. The Azure portal provides an "Execution History" tab that shows success, warning, or error messages for every run. If your indexer fails, the error message will usually point to a specific document or a connection timeout, allowing you to debug the issue efficiently.
Advanced Indexing: Skillsets and AI Enrichment
One of the most important aspects of modern knowledge mining is the ability to extract meaning from data that isn't just plain text. This is where AI Enrichment comes in. By attaching a "Skillset" to your indexer, you can inject AI processing into the ingestion pipeline.
A skillset is a sequence of cognitive skills that analyze your data. For example, you can use:
- OCR (Optical Character Recognition): To extract text from images or scanned documents.
- Key Phrase Extraction: To automatically pull out important topics from long-form text.
- Entity Recognition: To identify people, organizations, or locations mentioned in documents.
- Translation: To convert text from one language to another during the ingestion process.
When you use a skillset, the indexer becomes a data processing pipeline. As it crawls a document, it passes the content through these skills, and the output of those skills is then mapped to fields in your index. This allows you to search for documents not just by the words they contain, but by the concepts they discuss.
Callout: Skillsets and Cost Management While AI enrichment is incredibly powerful, it consumes resources. Every document processed through a cognitive skill incurs costs based on the complexity of the operation and the number of pages or characters processed. Always monitor your usage in the Azure portal to ensure your enrichment pipeline stays within budget.
Best Practices for Data Ingestion
Building a search solution is an iterative process. To ensure your system performs well and remains maintainable, follow these industry-standard practices:
1. Implement Incremental Indexing
Never re-index your entire dataset if you don't have to. Azure AI Search indexers support "change detection." For SQL databases, this is often handled by a "high water mark" column (like a RowVersion or LastModified timestamp). The indexer only processes rows that have changed since the last run, which significantly reduces the time and compute resources required.
2. Use Field Mappings Wisely
Don't just dump all your source data into the index. Only index the fields that you actually need for searching, filtering, or displaying in search results. Storing unnecessary data increases the size of your index, which leads to higher storage costs and slower query performance.
3. Handle Errors Gracefully
When dealing with large datasets, it is inevitable that some documents will fail to index (e.g., a corrupted PDF or a document with an unsupported character set). Configure your indexer to continue on error rather than stopping the entire process. You can set a limit for the number of errors allowed before the indexer stops, ensuring that the majority of your data is indexed while keeping the process robust.
4. Optimize for Searchability
Think about how your users will search. If they need to search for partial strings (like part numbers), you may need to use custom analyzers. If they need to search by category, ensure those fields are marked as "filterable." Planning your schema before you run your first indexer will save you from having to rebuild the index later.
Common Pitfalls and How to Avoid Them
Even experienced engineers run into challenges with indexers. Here are the most common mistakes and how to avoid them:
- Ignoring Document Size Limits: Azure AI Search has limits on the size of the documents it can process. If you are uploading massive files, they may fail during extraction. Always check the official documentation for the maximum size limits of your specific service tier.
- Hardcoding Credentials: Never put connection strings or storage keys directly into your application code or source control. Use Azure Key Vault to store secrets and reference them in your indexer configuration.
- Over-Indexing: Adding too many cognitive skills can turn your indexer into a bottleneck. If you need to perform heavy AI analysis, consider pre-processing your data in an Azure Function or an Azure Batch job before it hits the search index.
- Inconsistent Data Types: Ensure that the data coming from your source matches the data types defined in your index. For example, trying to push a string into a field defined as an
Edm.Int32will cause the indexer to fail for that record.
Comparison of Indexing Strategies
To help you decide the best approach for your project, refer to the following comparison of common ingestion strategies:
| Strategy | Best For | Pros | Cons |
|---|---|---|---|
| Indexer-based | Standard data sources (SQL, Blob, Cosmos) | Fully automated, change detection, easy to set up | Less control over complex data transformations |
| Push API | Real-time updates, custom data sources | Fine-grained control, immediate availability | Requires custom code to manage state and batches |
| Hybrid | Large scale, mixed data types | Flexibility to combine both methods | More complex to maintain and monitor |
Security Considerations
Security is paramount when dealing with enterprise data. When you configure a data source, you are essentially granting the search service access to your data. To secure this connection:
- Use Managed Identities: Whenever possible, use an Azure Managed Identity for the search service. This allows the search service to authenticate to storage accounts or SQL databases without needing to manage passwords or connection strings.
- Restrict Network Access: Use Private Endpoints to ensure that the traffic between your data source and Azure AI Search never leaves the Microsoft backbone network. This effectively isolates your data from the public internet.
- Principle of Least Privilege: When setting up access for the indexer, ensure that the identity has the minimum permissions necessary. For example, a read-only role on a Blob container is sufficient for an indexer; it does not need "Owner" or "Contributor" access.
Automating the Lifecycle
In a production environment, you should treat your search configuration as code. Use Terraform, Bicep, or Azure Resource Manager (ARM) templates to define your data sources and indexers. This allows you to version control your infrastructure, replicate environments (e.g., dev, staging, production), and automate deployments through CI/CD pipelines.
When you use infrastructure-as-code, you ensure consistency across environments. For example, you can define an indexer in a Bicep file:
resource myIndexer 'Microsoft.Search/searchServices/indexers@2023-11-01' = {
name: 'my-production-indexer'
parent: searchService
properties: {
dataSourceName: 'my-production-datasource'
targetIndexName: 'my-production-index'
schedule: {
interval: 'PT1H'
}
}
}
This approach eliminates the "it worked on my machine" problem and provides a clear audit trail of changes made to your data ingestion pipeline.
Managing Data Freshness
One of the most frequent questions regarding indexers is how to keep the index fresh. While the scheduling feature (e.g., running every hour) works for many use cases, some applications require near-real-time updates.
If you have a requirement for near-real-time updates, you have two primary options:
- High-Frequency Scheduling: You can set the indexer schedule to run as frequently as every five minutes. This is sufficient for many business scenarios where a slight delay is acceptable.
- Push API Integration: For scenarios requiring sub-second latency, you should bypass the indexer for those specific updates and use the Push API. You can write an Azure Function that triggers on a data change (e.g., a database trigger or a Blob storage event) and pushes the change directly to the index.
Note: Combining Indexers and Push API You can actually use both. You can use an indexer to handle the bulk of your data and maintain a baseline, while using the Push API to handle high-priority, real-time updates for specific documents. This "hybrid" approach offers the best of both worlds: the reliability of the indexer and the speed of the API.
Advanced Troubleshooting: The "Why is my data missing?" Checklist
If you find that data is missing from your index, follow this logical troubleshooting path:
- Check Indexer Status: Is the indexer actually running? Check the
lastResultin the indexer status. - Verify Data Source Connectivity: Can the indexer reach the data? If you are using a firewall, ensure the Azure AI Search service IP range is allowed.
- Check Mapping Logic: Did you accidentally exclude the field in the indexer mapping? Sometimes fields are mapped, but they are not marked as "searchable" in the index definition.
- Review Document Processing Errors: The indexer status will often list specific documents that failed. Look for reasons like "invalid data type" or "too many tokens."
- Test the Query: Sometimes the data is in the index, but the query is wrong. Use the Search Explorer in the Azure portal to run a simple
search=*query to see if the documents appear at all.
Understanding Analyzers and Tokenizers
While the indexer brings the data in, the way that data is stored and searched depends heavily on analyzers. An analyzer breaks text into smaller chunks called tokens. For example, "Azure AI Search" might be broken into "Azure", "AI", and "Search".
When you index data, you choose an analyzer for each field. If you are indexing simple names, the "keyword" analyzer might be best, as it treats the whole string as one token. If you are indexing long documents, a "standard" or "language-specific" analyzer is usually better. If you use the wrong analyzer, your search results will be poor, regardless of how well your indexer is configured.
Scaling Your Indexing Pipeline
As your data grows into the millions or billions of documents, your indexing strategy must evolve. Azure AI Search scales by adding "replicas" (for query performance) and "partitions" (for storage and indexing throughput).
If you are struggling with long indexing times:
- Increase Partitions: Adding more partitions increases the storage capacity and the parallel processing power of your indexer.
- Parallelize: If you have multiple data sources, don't put them all into one indexer. Create separate indexers for different data sets. This allows you to manage the schedule and performance of each source independently.
- Batching: When using the Push API, always send data in batches. Sending one document at a time is extremely inefficient and will lead to high latency and unnecessary overhead.
The Future of Knowledge Mining
We are currently seeing a shift toward "vector search" and "semantic search." In these models, the indexer doesn't just extract text; it calls an embedding model (like those found in Azure OpenAI) to convert your data into high-dimensional vectors.
When you set up an indexer for vector search, the pipeline looks different:
- The indexer retrieves the document.
- It sends the document to an embedding model.
- The model returns a vector (a list of numbers representing the meaning of the text).
- The indexer stores this vector in a
Collection(Edm.Single)field in your index.
This allows you to perform "concept-based" searches, where a user can search for "how to fix a flat tire" and find a document that says "repairing a punctured wheel," even if the words don't match exactly. Understanding the traditional indexer concepts discussed here is the prerequisite for moving into these advanced, AI-driven search architectures.
Key Takeaways
As we conclude this lesson on Data Sources and Indexers, keep these core principles in mind:
- Decoupling is Key: Keep your connection details (Data Sources) separate from your ingestion logic (Indexers) to ensure better security and maintainability.
- Automation Matters: Always use indexers for recurring ingestion tasks to keep your search index current without manual effort.
- Think in Pipelines: View the indexer not just as a data mover, but as a processing pipeline that can include AI enrichment, filtering, and transformation.
- Incremental is Efficient: Use change detection and high-water marks to avoid unnecessary re-indexing, which saves time, money, and computing power.
- Monitor and Debug: The indexer status and execution history are your best friends. Always check them after deployment and when troubleshooting missing data.
- Security First: Utilize managed identities and private endpoints to ensure that your data remains secure throughout the entire ingestion process.
- Plan Your Schema: A well-designed index schema, paired with the correct choice of analyzers, is just as important as the data you are ingesting.
By mastering these components, you are well on your way to building robust, scalable, and intelligent search solutions that effectively bridge the gap between raw data and actionable knowledge. Whether you are working with small databases or petabytes of unstructured content, the foundations you have learned here will serve as the backbone of your knowledge mining strategy.
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons