Do you want to offer your users the ability to do a Full-Text Search on their data? Or allow them to find a restaurant within a 20 miles radius from their location? What about the ability the tune the search results based on your requirements by adding weights to specific fields for example? Or what about faceted search, allowing your user to apply additional filters to the current results (Figure 1)?


Figure 1: Example of a faceted search

The new Microsoft Azure Search service makes all of these scenarios possible and more, allowing you to build a rich search experience for your users. In this article we’ll get you up to speed with the basic functionalities so you can get started right away.


To get started you’ll need to create a new Search Service in the Azure Portal, after which you’ll get the keys to access the REST API. At the moment there’s no official Client SDK available for Azure Search so you can use the library I created these past few weeks which covers version 2014-07-31-Preview of the API. The library is available on GitHub and as a NuGet package.

You can install the NuGet package by using the Visual Studio Package Manager or running the following from the NuGet command line: Install-Package RedDog.Search

Now we’ll create an index in which we’ll store movies. The goal is to allow users to find movies by their title, description, genre and IMDB rating. I started by creating a simple WinForms application in which I configure the management client and query client when the application starts (Figure 3).

Figure 2: Setting up the clients

The credentials are stored in the App.config and are used to initialize the ApiConnection, which connects to the Azure Search service. After that we initialize both the management client and the query client. The management client is used for index creation and population while the query client is used to execute searches.

Figure 3 shows how easy it is to create an index with different fields. Using the fluent interface we create the “imdb-movies” index with a few different fields:

  • id: Which is defined as the key. This key will be used when we want to retrieve, merge or delete a record.
  • title: This field is retrievable and searchable which will enable Full-Text Search on the field.
  • description: This field is retrievable and searchable which will enable Full-Text Search on the field.
  • rating: This field has been declared as a Double field with filtering support. Filtering allows us to create a rich search experience that goes beyond Full-text search. If we expose this on our website you might imagine that we’ll present the users with a slider where they can choose the minimum rating for the movies they are looking for. This will allow us to use this value in a filter with a syntax like ‘rating ge 5‘ which will only return the movies with a rating equal to or higher than 5.
  • genre: The genre field is defined as a string collection and this is useful for storing any kind of “tags” like data. Similar to the rating field this will allow us to do some advanced filtering on our movies, like searching for drama movies: ‘genre/any(t: t eq ‘Drama’)

Figure 3: Creating the Index

Adding Data to Our Index

And now it’s time to populate our index. You would typically get some data from your SQL Database, Table Storage or anywhere else and upload it to your index. In Figure 4 you’ll see how I’m calling the PopulateAsync method to upload a few records in the index.

Figure 4: Uploading data to the index

As you can see I’m sending a batch of 3 records in a single call. The recommended maximum at this time for batches is 1000 records or 16 Megabytes. The result of this call is a list that contains the status for each record that you sent to the index, with the key, the status, and an error message. A status of true means success. This feedback is useful to know which operations could not be committed to the index and why.


So now we have a simple index with a few records. Let’s see how easy it is to query our data. In the application we’re building I’ve added a simple search UI allowing users to do a Full-Text Search and to filter specific genres. Figure 5 shows how we build the query, execute it and use the results to create a DataTable and bind it to a DataGridView.

Figure 5: Creating a query and using the result

Figure 6 shows the final application in action after having searched for the term “hacker“.

And that’s it for our movie search application. If you want to test this for yourself go ahead and grab the code from the download link at the bottom of the article, or get the latest code from GitHub.


Figure 6: Searching for ‘hacker’

The RedDog Search Portal

At the moment it’s only possible to interact with Azure Search through the REST API. There’s no official Client SDK but also no UI to configure your indexes, test your queries, import data, etc.

To help people get started with Azure Search I created my own management portal for Azure Search, the RedDog Search Portal. This is an application built with AngularJS, the ASP.NET Web API and the RedDog Search library.

The portal allows you to create/edit/delete indexes, view the statistics, manage scoring profiles, import data and execute searches as you can see from Figures 7, 8 and 9.


Figure 7: Editing an index


Figure 8: Executing a search

The complete source is available on GitHub and you can run the application locally or host it in a Web Site or virtual machine.

We’re Just Getting Started

In this article we covered the tools that can get you started with Azure Search together with a simple search scenario to add Full-Text Search to your application. But we only covered a few of the features available in Azure Search. There’s much more available under the hood including:

  • Different field types
  • Advanced queries
  • Geo Search (finding results close to a specific point, …)
  • Faceted Search
  • Scoring Profiles (which allows you to tune your search results like: assign weights to specific fields, give recent results a better score, etc. )

Have fun!