title | description | services | documentationcenter | author | manager | editor | tags | ms.assetid | ms.service | ms.devlang | ms.workload | ms.topic | ms.tgt_pltfrm | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Get started with Azure Search | Microsoft Docs |
Learn how to create your first Azure Search index using this tutorial walkthrough and DocumentDB sample data. This portal-based, code-free exercise uses the Import Data wizard. |
search |
HeidiSteen |
jhubbard |
azure-portal |
21adc351-69bb-4a39-bc59-598c60c8f958 |
search |
na |
search |
hero-article |
na |
10/03/2016 |
heidist |
This code-free introduction gets you started with Microsoft Azure Search using capabilities built right into the portal.
The tutorial assumes a sample Azure DocumentDB database that's simple to create using our data and instructions, but you can also adapt these steps to your existing data in either DocumentDB or SQL Database.
Note
This Get Started tutorial requires an Azure subscription and an Azure Search service.
-
Sign in to the Azure portal.
-
Open the service dashboard of your Azure Search service. Here are a few ways to find the dashboard.
- In the Jumpbar, click Search services. The Jumpbar lists every service provisioned in your subscription. If a search service has been defined, you see Search services in the list.
- In the Jumpbar, click Browse and then type "search" in the search box to produce a list of all search services created in your subscriptions.
Many customers start with the free service. This version is limited to three indexes, three data sources, and three indexers. Make sure you have room for extra items before you begin. This walkthrough creates one of each object.
Search queries iterate over an index containing searchable data, metadata, and constructs used for optimizing certain search behaviors. As a first step, define and populate an index.
There are several ways to create an index. If your data is in a store that Azure Search can crawl - such as Azure SQL Database, SQL Server on an Azure VM, or DocumentDB - you can create and populate an index very easily using an indexer.
To keep this task portal-based, we use data from DocumentDB that can be crawled using an indexer via the Import data wizard.
Before you continue, create a sample DocumentDB database to use with this tutorial, and then return to this section to complete the steps below.
-
On your Azure Search service dashboard, click Import data in the command bar to start a wizard that both creates and populates an index.
-
In the wizard, click Data Source > DocumentDB > Name, type a name for the data source. A data source is a connection object in Azure Search that can be used with other indexers. Once you create it, it becomes available as an "existing data source" in your service.
-
Choose your existing DocumentDB account, and the database and collection. If you're using the sample data we provide, your data source definition looks like this:
Notice that we are skipping the query. This is because we're not implementing change tracking in our dataset this time around. If your dataset includes a field that keeps track of when a record is updated, you can configure an Azure Search indexer to use change tracking for selective updates to your index.
Click OK to complete this step of the wizard.
Still in the wizard, click Index and take a look at the design surface used to create an Azure Search index. Minimally, an index requires a name, and a fields collection, with one field marked as the document key. Because we're using a DocumentDB data set, fields are detected by the wizard automatically and the index is preloaded with fields and data type assignments.
Although the fields and data types are configured, you still need to assign attributes. The check boxes across the top of the field list are index attributes that control how the field is used.
- Retrievable means that it shows up in search results list. You can mark individual fields as off limits for search results by clearing this checkbox, for example when fields used only in filter expressions.
- Filterable, Sortable, and Facetable determine whether a field can be used in a filter, a sort, or a facet navigation structure.
- Searchable means that a field is included in full text search. Strings are usually searchable. Numeric fields and Boolean fields are often marked as not searchable.
Before you leave this page, mark the fields in your index to use the following options (Retrievable, Searchable, and so on). Most fields are Retrievable. Most string fields are Searchable (you don't need to make the Key searchable). A few fields like genre, orderableOnline, rating, and tags are also Filterable, Sortable, and Facetable.
Field | Type | Options |
---|---|---|
id | Edm.String | |
albumTitle | Edm.String | Retrievable, Searchable |
albumUrl | Edm.String | Retrievable, Searchable |
genre | Edm.String | Retrievable, Searchable, Filterable, Sortable, Facetable |
genreDescription | Edm.String | Retrievable, Searchable |
artistName | Edm.String | Retrievable, Searchable |
orderableOnline | Edm.Boolean | Retrievable, Filterable, Sortable, Facetable |
tags | Collection(Edm.String) | Retrievable, Filterable, Facetable |
price | Edm.Double | Retrievable, Filterable, Facetable |
margin | Edm.Int32 | |
rating | Edm.Int32 | Retrievable, Filterable, Sortable, Facetable |
inventory | Edm.Int32 | Retrievable |
lastUpdated | Edm.DateTimeOffset |
As a point of comparison, the following screenshot is an illustration of an index built to the specification in the previous table.
Click OK to complete this step of the wizard.
Still in the Import data wizard, click Indexer > Name, type a name for the indexer, and use defaults for all the other values. This object defines an executable process. Once you create it, you could put it on recurring schedule, but for now use the default option to run the indexer once, immediately, when you click OK.
Your import data entries should be all filled in and ready to go.
To run the wizard, click OK to start the import and close the wizard.
To check progress, go back to the service dashboard, scroll down, and double-click the Indexers tile to open the indexers list. You should see the indexer you just created in the list, and you should see status indicating "in progress" or success, along with the number of documents indexed into Azure Search.
You now have a search index that's ready to query.
Search explorer is a query tool built into the portal. It provides a search box so that you can verify a search input returns the data you expect.
- Click Search explorer on the command bar.
- Notice which index is active. If it's not the one you just created, click Change index on the command bar to select the one you want.
- Leave the search box empty and then click the Search button to execute a wildcard search that returns all documents.
- Enter a few full-text search queries. You can review the results from your wildcard search to get familiar with artists, albums, and genres to query.
- Try other query syntax using the examples provided at the end of this article for ideas, modifying your query to use search strings that are likely to be found in your index.
After you run the wizard once, you can go back and view or modify individual components: index, indexer, or data source. Some edits, such as the changing the field data type, are not allowed on the index, but most properties and settings are modifiable. To view individual components, click the Index, Indexer, or Data Sources tiles on your dashboard to display a list of existing objects.
To learn more about other features mentioned in this article, visit these links:
- Indexers
- Create Index (includes a detailed explanation of the index attributes)
- Search Explorer
- Search Documents (includes examples of query syntax)
You can try this same workflow, using the Import data wizard for other data sources like Azure SQL Database or SQL Server on Azure virtual machines.
Note
Newly announced is indexer support for crawling Azure Blob Storage, but that feature is in preview and not yet a portal option. To try that indexer, you need to write code. See Indexing Azure Blob storage in Azure Search for more information.
This section creates a small database in DocumentDB that can be used to complete the tasks in this tutorial.
The following instructions give you general guidance, but are not exhaustive. If you need more help with DocumentDB portal navigation or tasks, you can refer to DocumentDB documentation, but most of the commands you need are either in the service command bar at the top of the dashboard or in the database blade.
- Click here to download a ZIP file containing the music store JSON data files. We provide 246 JSON documents for this dataset.
- Add DocumentDB to your subscription and then open the service dashboard.
- Click Add Database to create a new database with an id of
musicstoredb
. It shows up in the database tile further down the page after it's created. - Click on the database name to open the database blade.
- Click Add Collection to create a collection with an id of
musicstorecoll
. - Click Document Explorer.
- Click Upload.
- In Upload Document, navigate to the local folder that contains the JSON files you downloaded previously. Select JSON files in batches of 100 or fewer.
- 386.json
- 387.json
- . . .
- 486.json
- Repeat to get the next batch of files until you've uploaded the last one, 669.json.
- Click Query Explorer to verify the data is uploaded to meet the upload requirements of Document Explorer.
An easy way to do this is to use the default query, but you can also modify the default query so that it selects the top 300 (there are fewer than 300 items in this dataset).
You should get back JSON output, starting with document number 386, and ending with document 669. Once the data is loaded, you can return to the steps in this walkthrough to build an index using the Import data wizard.