Quickstart: Create a search index in the Azure portal
In this Azure AI Search quickstart, create your first search index using the Import data wizard and a built-in sample of fictitious hotel data hosted by Microsoft. 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, we review each object.
Note
The Import data wizard includes options for OCR, text translation, and other AI enrichments that aren't covered in this quickstart. For a similar walkthrough that focuses on applied AI, see Quickstart: Create a skillset in the Azure portal.
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.
Familiarity with the wizard. See Import data wizards in the Azure portal for details.
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 tab, select Usage to see how many indexes, indexers, and data sources you currently have.
Start the wizard
Sign in to the Azure portal.
Go to your search service.
On the Overview tab, select Import data to start the wizard.
Create and load a search index
In this section, you create and load an index in four steps:
- Connect to a data source
- Skip configuration for cognitive skills
- Configure the index
- Configure and run the indexer
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:
On Connect to your data, expand the Data Source dropdown list and select Samples.
Select hotels-sample from the list of built-in samples.
Select Next: Add cognitive skills (Optional) to continue.
Skip configuration for cognitive skills
Although the wizard supports skillset creation and AI enrichment during indexing, cognitive skills are beyond the scope of this quickstart.
To skip this step in the wizard:
On Add cognitive skills, ignore the AI enrichment configuration options.
Select Next: Customize target index to continue.
Tip
To get started with AI enrichment, see Quickstart: Create a skillset in the Azure portal.
Configure the index
The wizard infers a schema for the hotels-sample index. To configure the index:
Accept the system-generated values for the Index name (hotels-sample-index) and Key (HotelId).
Accept the system-generated values for all field attributes.
Select Next: Create an indexer to continue.
At a minimum, the search 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, a data type, and attributes that control how the field is used in the index. 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
Finally, you configure and run the indexer, which defines an executable process. The data source and index are also created in this step.
To configure and run the indexer:
Accept the system-generated value for the Indexer name (hotels-sample-indexer).
For this quickstart, use the default option to run the indexer immediately and only once. The sample data is static, so you can't enable change tracking.
Select Submit to simultaneously create and run the indexer.
Monitor indexer progress
You can monitor the creation of the indexer and index in the Azure portal. The Overview tab provides links to the resources created in your search service.
To monitor the progress of the indexer:
Go to your search service in the Azure portal.
From the left pane, select Indexers.
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
Go to your search service in the Azure portal.
From the left pane, select Indexes.
Select hotels-sample-index. If the index has zero documents or storage, wait for the Azure portal to refresh.
Select the Fields tab to view the index schema.
Check which fields are Filterable or Sortable so that you know what queries to write.
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 the Search POST REST API. This tool supports simple query syntax and full Lucene query syntax.
To query your search index:
On the Search explorer tab, enter text to search on.
To jump to nonvisible areas of the output, use the mini map.
To specify syntax, switch to the JSON view.
Example queries for hotels-sample index
The following examples assume the JSON view and the 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 type a space character to see a list of all query parameters. You can also type 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. To learn more about queries, 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 for your service under All resources or Resource groups in 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 steps
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.