Edit

Share via


Quickstart: Create a search index in the Azure portal

Important

The Import data (new) wizard now supports keyword search, which was previously only available in the Import data wizard. We recommend the new wizard for an improved search experience. For more information about how we're consolidating the wizards, see Import data wizards in the Azure portal.

In this quickstart, you use the Import data (new) wizard and sample data about fictitious hotels to create your first search index. The wizard requires no code to create an index, helping you write interesting queries within minutes.

The wizard creates multiple objects on your search service, including a searchable index, an indexer, and a data source connection for automated data retrieval. At the end of this quickstart, you review each object.

Prerequisites

  • An Azure account with an active subscription. Create an account for free.

  • An Azure AI Search service. Create a service or find an existing service in your current subscription. You can use a free service for this quickstart.

  • An Azure Storage account. Use Azure Blob Storage or Azure Data Lake Storage Gen2 (storage account with a hierarchical namespace) on a standard performance (general-purpose v2) account. To avoid bandwidth charges, use the same region as Azure AI Search.

Check for network access

For this quickstart, all of the preceding resources must have public access enabled so that the Azure portal nodes can access them. Otherwise, the wizard fails. After the wizard runs, you can enable firewalls and private endpoints on the integration components for security. For more information, see Secure connections in the import wizards.

Check for space

Many customers start with a free search service, which is limited to three indexes, three indexers, and three data sources. This quickstart creates one of each, so before you begin, make sure you have room for extra objects.

On the Overview page, select Usage to see how many indexes, indexers, and data sources you currently have.

Screenshot of the Overview page for an Azure AI Search service instance in the Azure portal, showing the number of indexes, indexers, and data sources.

Prepare sample data

This quickstart uses a JSON document that contains metadata for 50 fictitious hotels, but you can also use your own files.

To prepare the sample data for this quickstart:

  1. Sign in to the Azure portal and select your Azure Storage account.

  2. From the left pane, select Data storage > Containers.

  3. Create a container named hotels-sample.

  4. Upload the sample JSON document to the container.

Start the wizard

To start the wizard for this quickstart:

  1. Sign in to the Azure portal and select your search service.

  2. On the Overview page, select Import data (new).

    Screenshot that shows how to open the new import wizard in the Azure portal.

  3. Select your data source: Azure Blob Storage or Azure Data Lake Storage Gen2.

    Screenshot of the options for selecting a data source in the wizard.

  4. Select Keyword search.

    Screenshot of the keyword search tile in the Azure portal.

Create and load a search index

In this section, you create and load an index in five steps.

Connect to a data source

Azure AI Search requires a connection to a data source for content ingestion and indexing. In this case, the data source is your Azure Storage account.

To connect to the sample data:

  1. On the Connect to your data page, select your Azure subscription.

  2. Select your storage account, and then select the hotels-sample container.

  3. Select JSON array for the parsing mode.

    Screenshot of the Connect to your data page in the Azure portal.

  4. Select Next.

Skip configuration for skills

The wizard supports skillset creation and AI enrichment during indexing, which are beyond the scope of this quickstart. Skip this step by selecting Next.

Tip

For a similar walkthrough that focuses on AI enrichment, see Quickstart: Create a skillset in the Azure portal.

Configure the index

Based on the structure and content of the sample hotel data, the wizard infers a schema for your search index.

To configure the index:

  1. For each of the following fields, select Configure field, and then set the respective attributes.

    Fields Attributes
    HotelId Key, Retrievable, Filterable, Sortable, Searchable
    HotelName, Category Retrievable, Filterable, Sortable, Searchable
    Description, Description_fr Retrievable
    Tags Retrievable, Filterable, Searchable
    ParkingIncluded, IsDeleted, LastRenovationDate, Rating, Location Retrievable, Filterable, Sortable
    Address.StreetAddress, Rooms.Description, Rooms.Description_fr Retrievable, Searchable
    Address.City, Address.StateProvince, Address.PostalCode, Address.Country, Rooms.Type, Rooms.BedOptions, Rooms.Tags Retrievable, Filterable, Facetable, Searchable
    Rooms.BaseRate, Rooms.SleepsCount, Rooms.SmokingAllowed Retrievable, Filterable, Facetable

    GIF that shows how to configure attributes for fields in the index.

  2. Delete the AzureSearch_DocumentKey field.

  3. Select Next.

At a minimum, the index requires a name and a collection of fields. The wizard scans for unique string fields and marks one as the document key, which uniquely identifies each document in the index.

Each field has a name, data type, and attributes that control how the field is used in the index. You can enable or disable the following attributes:

Attribute Description Applicable data types
Retrievable Fields returned in a query response. Strings and integers
Filterable Fields that accept a filter expression. Integers
Sortable Fields that accept an orderby expression. Integers
Facetable Fields used in a faceted navigation structure. Integers
Searchable Fields used in full-text search. Strings are searchable, but numeric and Boolean fields are often marked as not searchable. Strings

Attributes affect storage in different ways. For example, filterable fields consume extra storage, while retrievable fields don't. For more information, see Example demonstrating the storage implications of attributes and suggesters.

If you want autocomplete or suggested queries, specify language Analyzers or Suggesters.

Skip advanced settings

The wizard offers advanced settings for semantic ranking and index scheduling, which are beyond the scope of this quickstart. Skip this step by selecting Next.

Review and create the objects

The last step is to review your configuration and create the index, indexer, and data source on your search service. The indexer automates the process of extracting content from your data source and loading it into the index, enabling keyword search.

To review and create the objects:

  1. Change the object name prefix to hotels-sample.

  2. Review the object configurations.

    Screenshot of the object configuration page in the Azure portal.

    AI enrichment, semantic ranker, and indexer scheduling are either disabled or set to their default values because you skipped their wizard steps.

  3. Select Create to simultaneously create the objects and run the indexer.

Important

The Import data wizard will eventually be deprecated. Most of its functionality is available in the Import data (new) wizard, which we recommend for most search scenarios. For more information, see Import data wizards in the Azure portal.

In this quickstart, you use the Import data wizard and a built-in sample of fictitious hotel data to create your first search index. The wizard requires no code to create an index, helping you write interesting queries within minutes.

The wizard creates multiple objects on your search service, including a searchable index, an indexer, and a data source connection for automated data retrieval. At the end of this quickstart, you review each object.

Prerequisites

Check for network access

For this quickstart, which uses built-in sample data, make sure your search service doesn't have network access controls. The Azure portal controller uses a public endpoint to retrieve data and metadata from the Microsoft-hosted data source. For more information, see Secure connections in the import wizards.

Check for space

Many customers start with a free search service, which is limited to three indexes, three indexers, and three data sources. This quickstart creates one of each, so before you begin, make sure you have room for extra objects.

On the Overview page, select Usage to see how many indexes, indexers, and data sources you currently have.

Screenshot of the Overview page for an Azure AI Search service instance in the Azure portal, showing the number of indexes, indexers, and data sources.

Start the wizard

To start the wizard for this quickstart:

  1. Sign in to the Azure portal and select your search service.

  2. On the Overview page, select Import data.

    Screenshot that shows how to open the Import data wizard in the Azure portal.

Create and load a search index

In this section, you create and load an index in four steps.

Connect to a data source

The wizard creates a data source connection to sample data that Microsoft hosts on Azure Cosmos DB. The sample data is accessed through a public endpoint, so you don't need an Azure Cosmos DB account or source files for this step.

To connect to the sample data:

  1. On the Connect to your data page, select the Data Source dropdown list, and then select Samples.

  2. Select hotels-sample from the list of built-in samples.

  3. Select Next: Add cognitive skills (Optional).

    Screenshot that shows how to select the hotels-sample data source in the Import data wizard.

Skip configuration for skills

The wizard supports skillset creation and AI enrichment during indexing, which are beyond the scope of this quickstart. Skip this step by selecting Next: Customize target index.

Tip

For a similar walkthrough that focuses on AI enrichment, see Quickstart: Create a skillset in the Azure portal.

Configure the index

Based on the structure and content of the sample hotel data, the wizard infers a schema for your search index.

To configure the index:

  1. Accept the system-generated values for the index name (hotels-sample-index) and key (HotelId).

  2. Accept the system-generated values for all field attributes.

  3. Select Next: Create an indexer.

    Screenshot that shows the generated index definition for the hotels-sample data source in the Import data wizard.

At a minimum, the index requires a name and a collection of fields. The wizard scans for unique string fields and marks one as the document key, which uniquely identifies each document in the index.

Each field has a name, data type, and attributes that control how the field is used in the index. You can use the checkboxes to enable or disable the following attributes:

Attribute Description Applicable data types
Retrievable Fields returned in a query response. Strings and integers
Filterable Fields that accept a filter expression. Integers
Sortable Fields that accept an orderby expression. Integers
Facetable Fields used in a faceted navigation structure. Integers
Searchable Fields used in full-text search. Strings are searchable, but numeric and Boolean fields are often marked as not searchable. Strings

Attributes affect storage in different ways. For example, filterable fields consume extra storage, while retrievable fields don't. For more information, see Example demonstrating the storage implications of attributes and suggesters.

If you want autocomplete or suggested queries, specify language Analyzers or Suggesters.

Configure and run the indexer

The last step is to configure and run the indexer, which automates the process of extracting content from your data source and loading it into your index. This step also creates the data source and index objects on your search service.

To configure and run the indexer:

  1. Accept the system-generated value for the indexer name (hotels-sample-indexer).

  2. Accept the default schedule option to run the indexer once and immediately. The sample data is static, so you can't enable change tracking.

  3. Select Submit to simultaneously create and run the indexer.

    Screenshot that shows how to configure the indexer for the hotels-sample data source in the Import data wizard.

Monitor indexer progress

You can monitor the creation of the indexer and index in the Azure portal. The Overview page provides links to the objects created on your search service.

To monitor the progress of the indexer:

  1. From the left pane, select Indexers.

  2. Find hotels-sample-indexer in the list.

    Screenshot that shows the creation of the indexer in progress in the Azure portal.

    It can take a few minutes for the results to update. You should see the newly created indexer with a status of In progress or Success. The list also shows the number of documents indexed.

Check search index results

  1. From the left pane, select Indexes.

  2. Select hotels-sample-index. If the index has zero documents or storage, wait for the Azure portal to refresh.

    Screenshot of the Indexes list on the Azure AI Search service dashboard in the Azure portal.

  3. Select the Fields tab to view the index schema.

  4. Check which fields are Filterable or Sortable so that you know what queries to write.

    Screenshot that shows the schema definition for an index in the Azure AI Search service in the Azure portal.

Add or change fields

On the Fields tab, you can create a field by selecting Add field and specifying a name, supported data type, and attributes.

Changing existing fields is more difficult. Existing fields have a physical representation in the search index, so they aren't modifiable, not even in code. To fundamentally change an existing field, you must create a new field to replace the original. You can add other constructs, such as scoring profiles and CORS options, to an index at any time.

Review the index definition options to understand what you can and can't edit during index design. If an option appears dimmed, you can't modify or delete it.

Query with Search explorer

You now have a search index that can be queried using Search explorer, which sends REST calls that conform to Documents - Search Post (REST API). This tool supports simple query syntax and full Lucene query syntax.

To query your search index:

  1. On the Search explorer tab, enter text to search on.

    Screenshot that shows how to enter and run a query in the  Search Explorer tool.

  2. To jump to nonvisible areas of the output, use the mini map.

    Screenshot that shows long results for a query in the Search Explorer tool and the mini-map.

  3. To specify syntax, switch to the JSON view.

    Screenshot of the JSON view selector.

Example queries for hotels-sample index

The following examples assume the JSON view and 2024-05-01-preview REST API version.

Tip

The JSON view supports intellisense for parameter name completion. Place your cursor inside the JSON view and enter a space character to see a list of all query parameters. You can also enter a letter, like s, to see only the query parameters that begin with that letter.

Intellisense doesn't exclude invalid parameters, so use your best judgment.

Filter examples

Parking, tags, renovation date, rating, and location are filterable.

{
    "search": "beach OR spa",
    "select": "HotelId, HotelName, Description, Rating",
    "count": true,
    "top": 10,
    "filter": "Rating gt 4"
}

Boolean filters assume "true" by default.

{
    "search": "beach OR spa",
    "select": "HotelId, HotelName, Description, Rating",
    "count": true,
    "top": 10,
    "filter": "ParkingIncluded"
}

Geospatial search is filter based. The geo.distance function filters all results for positional data based on the specified Location and geography'POINT coordinates. The query seeks hotels within five kilometers of the latitude and longitude coordinates -122.12 47.67, which is "Redmond, Washington, USA." The query displays the total number of matches &$count=true with the hotel names and address locations.

{
    "search": "*",
    "select": "HotelName, Address/City, Address/StateProvince",
    "count": true,
    "top": 10,
    "filter": "geo.distance(Location, geography'POINT(-122.12 47.67)') le 5"
}

Full Lucene syntax examples

The default syntax is simple syntax, but if you want fuzzy search, term boosting, or regular expressions, specify the full syntax.

{
    "queryType": "full",
    "search": "seatle~",
    "select": "HotelId, HotelName,Address/City, Address/StateProvince",
    "count": true
}

Misspelled query terms, like seatle instead of Seattle, don't return matches in a typical search. The queryType=full parameter invokes the full Lucene query parser, which supports the tilde (~) operand. When you use these parameters, the query performs a fuzzy search for the specified keyword and matches on terms that are similar but not an exact match.

Take a minute to try these example queries on your index. For more information, see Querying in Azure AI Search.

Clean up resources

When you work 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.

In the Azure portal, you can find and manage resources by selecting All resources or Resource groups from the left pane.

Note

If you're using a free search service, remember that the limit is three indexes, three indexers, and three data sources. You can delete individual objects in the Azure portal to stay under the limit.

Next step

Try an Azure portal wizard to generate a ready-to-use web app that runs in a browser. Use this wizard on the small index you created in this quickstart, or use one of the built-in sample datasets for a richer search experience.