Quickstart: Create an Azure Cognitive Search skillset in the Azure portal

Learn how AI enrichment in Azure Cognitive Search adds Optical Character Recognition (OCR), image analysis, language detection, text translation, and entity recognition to create searchable content in a search index.

In this quickstart, you'll run the Import data wizard to apply skills that transform and enrich content during indexing. Output is a searchable index containing AI-generated image text, captions, and entities. Enriched content is queryable in the portal using Search explorer.

To prepare, you'll create a few resources and upload sample files before running the wizard.

Prefer to start with code? Try the .NET tutorial, Python tutorial, or REST tutorial instead.

Prerequisites

Before you begin, have the following prerequisites in place:

Note

This quickstart uses Cognitive Services for the AI. Because the workload is so small, Cognitive Services is tapped behind the scenes for free processing for up to 20 transactions. You can complete this exercise without having to create a Cognitive Services resource.

Set up your data

In the following steps, set up a blob container in Azure Storage to store heterogeneous content files.

  1. Download sample data consisting of a small file set of different types. Unzip the files.

  2. Sign in to the Azure portal with your Azure account.

  3. Create an Azure Storage account or find an existing account.

    • Choose the same region as Azure Cognitive Search to avoid bandwidth charges.

    • Choose the StorageV2 (general purpose V2).

  4. In Azure portal, open your Azure Storage page and create a container. You can use the default public access level.

  5. In Container, select Upload to upload the sample files you downloaded in the first step. Notice that you have a wide range of content types, including images and application files that are not full text searchable in their native formats.

    Screenshot of source files in Azure Blob Storage.

You are now ready to move on the Import data wizard.

Run the Import data wizard

  1. Sign in to the Azure portal with your Azure account.

  2. Find your search service and on the Overview page, select Import data on the command bar to set up cognitive enrichment in four steps.

    Screenshot of the Import data command.

Step 1 - Create a data source

  1. In Connect to your data, choose Azure Blob Storage.

  2. Choose an existing connection to the storage account and select the container you created. Give the data source a name, and use default values for the rest.

    Screenshot of the data source definition page.

    Continue to the next page.

Step 2 - Add cognitive skills

Next, configure AI enrichment to invoke OCR, image analysis, and natural language processing.

  1. For this quickstart, we are using the Free Cognitive Services resource. The sample data consists of 14 files, so the free allotment of 20 transaction on Cognitive Services is sufficient for this quickstart.

    Screenshot of the Attach Cognitive Services tab.

  2. Expand Add enrichments and make six selections.

    Enable OCR to add image analysis skills to wizard page.

    Choose entity recognition (people, organizations, locations) and image analysis skills (tags, captions).

    Screenshot of the skillset definition page.

    Continue to the next page.

Step 3 - Configure the index

An index contains your searchable content and the Import data wizard can usually create the schema for you by sampling the data source. In this step, review the generated schema and potentially revise any settings. Below is the default schema created for the demo Blob data set.

For this quickstart, the wizard does a good job setting reasonable defaults:

  • Default fields are based on metadata properties for existing blobs, plus the new fields for the enrichment output (for example, people, organizations, locations). Data types are inferred from metadata and by data sampling.

  • Default document key is metadata_storage_path (selected because the field contains unique values).

  • Default attributes are Retrievable and Searchable. Searchable allows full text search a field. Retrievable means field values can be returned in results. The wizard assumes you want these fields to be retrievable and searchable because you created them via a skillset. Select Filterable if you want to use fields in a filter expression.

    Screenshot of the index definition page.

Marking a field as Retrievable does not mean that the field must be present in the search results. You can control search results composition by using the $select query parameter to specify which fields to include.

Continue to the next page.

Step 4 - Configure the indexer

The indexer drives the indexing process. It specifies the data source name, a target index, and frequency of execution. The Import data wizard creates several objects, including an indexer that you can reset and run repeatedly.

  1. In the Indexer page, you can accept the default name and select Once to run it immediately.

    Screenshot of the indexer definition page.

  2. Click Submit to create and simultaneously run the indexer.

Monitor status

Cognitive skills indexing takes longer to complete than typical text-based indexing, especially OCR and image analysis. To monitor progress, go to the Overview page and select Indexers in the middle of page.

Screenshot of the indexer status page.

To check details about execution status, select an indexer from the list, and then select Success (or Failed) to view execution details.

In this demo, there is one warning: `"Could not execute skill because one or more skill input was invalid." It tells you that a PNG file in the data source doesn't provide a text input to Entity Recognition. This warning occurs because the upstream OCR skill didn't recognize any text in the image, and thus could not provide a text input to the downstream Entity Recognition skill.

Warnings are common in skillset execution. As you become familiar with how skills iterate over your data, you'll begin to notice patterns and learn which warnings are safe to ignore.

Query in Search explorer

After an index is created, run queries in Search explorer to return results.

  1. On the search service dashboard page, select Search explorer on the command bar.

  2. Select Change Index at the top to select the index you created.

  3. Enter a search string to query the index, such as search=Satya Nadella&$select=people,organizations,locations&$count=true.

Results are returned as verbose JSON, which can be hard to read, especially in large documents. Some tips for searching in this tool include the following techniques:

  • Append $select to limit the fields returned in results.
  • Use CTRL-F to search within the JSON for specific properties or terms.

Query strings are case-sensitive so if you get an "unknown field" message, check Fields or Index Definition (JSON) to verify name and case.

Screenshot of the the Search explorer page.

Takeaways

You've now created your first skillset and learned important concepts useful for prototyping an enriched search solution using your own data.

Some key concepts that we hope you picked up include the dependency on Azure data sources. A skillset is bound to an indexer, and indexers are Azure and source-specific. Although this quickstart uses Azure Blob Storage, other Azure data sources are possible. For more information, see Indexers in Azure Cognitive Search.

Another important concept is that skills operate over content types, and when working with heterogeneous content, some inputs will be skipped. Also, large files or fields might exceed the indexer limits of your service tier. It's normal to see warnings when these events occur.

Output is directed to a search index, and there is a mapping between name-value pairs created during indexing and individual fields in your index. Internally, the portal sets up annotations and defines a skillset, establishing the order of operations and general flow. These steps are hidden in the portal, but when you start writing code, these concepts become important.

Finally, you learned that can verify content by querying the index. In the end, what Azure Cognitive Search provides is a searchable index, which you can query using either the simple or fully extended query syntax. An index containing enriched fields is like any other. If you want to incorporate standard or custom analyzers, scoring profiles, synonyms, faceted navigation, geo-search, or any other Azure Cognitive Search feature, you can certainly do so.

Clean up resources

When you're working in your own subscription, it's a good idea at the end of a project to identify whether you still need the resources you created. Resources left running can cost you money. You can delete resources individually or delete the resource group to delete the entire set of resources.

You can find and manage resources in the portal, using the All resources or Resource groups link in the left-navigation pane.

If you are using a free service, remember that you are limited to three indexes, indexers, and data sources. You can delete individual items in the portal to stay under the limit.

Next steps

You can create skillsets using the portal, .NET SDK, or REST API. To further your knowledge, try the REST API using Postman and more sample data.