Creating Index For Azure Search Service

In this article, we will learn how to create an index for the Azure Search Service.

In our previous articles related to Azure Search Service, we have learned the following.

In this article, as highlighted below, we will create an index in the Azure Search Service that we have created in our previous articles, mentioned above.



What is an Index in Azure Search Service?

An index is like a persistent storage medium of the data, typically called documents. It’s like a database table where you have rows (or entities). Each Index has a name and a set of fields. We will learn how to create these fields, in a moment.

Why should we create an Index?

As discussed in previous articles, we should let the Azure Search Service know our application-specific data so that it can process and do all the analysis related to search, in order for us to consume the Azure Search capabilities by running Search Queries to Azure Search.

So, we need to first create the Index,  and then load the data. This article focuses on creating the Index only.

Navigate to the Search Service that we have created, as shown below.



As shown in the above screen, click on "Add Index" button to open the following "Add Index" blade where you enter the following details.

  • Index Name - Name of the Index
  • Index Fields - All the fields related to your application data.


Please provide a meaningful name in the Index name field and click on Fields button to open up the Fields blade, as shown below.



Below are a few of the details about the highlighted sections of the above screen.

  • Basic is the default tab that gets opened. There you define the Index Schema. This is similar to creating a database table with different columns and constraints.

  • Id field is the default field that gets created automatically with the datatype Edm.String.

  • By default, the Id field is tagged as the Key field. This is a kind of primary key.

Azure Search Index allows us to create eight type of fields which are shown below and all of them are self-explanatory.

  • Edm.String
  • Collection (Edm.String)
  • Edm.Int32
  • Edm.Int64
  • Edm.Double
  • Edm.BooleanEdm.DateTimeOffset
  • Edm.GeographicPoint

Let’s go-ahead and create the Index schema with our application specific data requirement. As an example, we will be having Employee information.

Below is the Index Schema that I have created.

Schema

Once you review your data, click OK button. You will be taken back to the "Add Index" blade, as shown below, with the number of fields that you have added.

Schema

Click OK now to create the Index. As shown below, we have successfully crated the Azure Search index.

Schema

Other important notes about Azure Search Index -

  • You cannot edit the Index definition as of this writing. In case you want to change the data type of a given field, you need to delete and recreate the Index.

  • You can have only one field with the attribute Key tagged to it.
Summary

In this article, we have learned the following.
  • What Azure Search Index is.
  • How to create an Index.
  • Different types of fields that we can create in an Index.

Hope, you enjoyed reading the article. Your feedback is appreciated. You can read the original article here.

Up Next
    Ebook Download
    View all
    Learn
    View all