Introduction to Azure Search
Introduction to Azure Search
Microsoft's new cloud service leverages the well-respected ElasticSearch. That can't be bad thing, right?
Join the DZone community and get the full member experience.Join For Free
Learn how to migrate and modernize stateless applications and run them in a Kubernetes cluster.
Azure Search is a new cloud service by Microsoft. I played with this service a little bit and now it is my favorite toy. In this post I give a quick overview of Azure Search and tell you what it is and what it is not. Also I provide some advice about what tools you need and how to get rid of some problems I faced when using service on CoreCLR.
Why Azure Search?
First let’s take a look at a picture of Microsoft search technologies and where Azure Search comes in. Below is the table of services built and provided by Microsoft. For all services I also added explanation why they don’t fit well for custom search scenarios.
|Desktop Search||Powers file search and search from mailboxes, used also by media services.||Not built for web scenarios or for big number of parallel users.|
|Bing||Web search, targeted to find web pages and files from web.||Search from web index, no options for custom structured data.|
|SharePoint Search||Perhaps most powerful enterprise-grade search solution available, highly customizable.||The best your money can buy but it is very expensive.|
|DocumentDB||NoSQL document database built by Microsoft and provided as a services on Azure.||Just a database with not much search semantics.|
Azure search is the missing piece of the puzzle – you can build custom search indices, customize these and search from indices from whatever application you have. For smaller loads there is also free search available on Azure.
Internals of Azure Search
Microsoft uses ElasticSearch as a search engine behind Azure Search service. Elastic Search is free search solution built on top of Lucene document database. For us there is a JSON-based API for search and this is how our applications communicate with search service.
NB! Our applications use only what Azure Search API provides. We have no direct access to search solution behind the API and actually for us it shouldn’t matter what Microsoft is actually using. Azure Search is not cloud-hosted Elastic Search.
Features of Azure Search
Here are some features of Azure Search:
- Indexers – update search index from SQL Azure or DocumentDB
- Faceted navigation – filtering mechanism that provides self-directed drilldown navigation in search applications
- Pagination – search results can be paged
- Scoring profiles – feature of Microsoft Azure Search that customize the calculation of search scores, influencing how items are ranked in a search results
- Suggesters – used for search-based auto-complete, by example
- Tab boosting – based on existing tags elements in index can get higher ranking score in results
- Language analyzers – analysis for fields that most frequently involve word-breaking, text normalization, and filtering out terms.
Managing Search Services
We can manage our search services through Azure preview portal. The screenshot below gives you some idea about what to expect.
Not all management options are available through preview portal – there are still some things you need to do through direct JSON calls to API. I hope over time all these options will find their way to management portal too.
Tools and Libraries
Here are tools and libraries you can use:
- There is a search library available on Nuget. It is by Microsoft and you can use it in your applications that use full version of .NET. NB! Today this library is not supported on CoreCLR.
- Have a REST client because there are things you can do only through API. There is RESTClient plug-in available for Firefox, for example.
- If your application is running on CoreCLR then you can write your own simple search client using JSON.NET by example.
- I faced issues on Visual Studio and CoreCLR when running code asynchronously. If you run into the same troubles then
Task.Wait()will do the trick but don’t consider this trick as a solution. It’s still bad hack but you get control over what is going on.
- As there are some hard limitations (you can’t change and delete existing fields in index) it’s a good idea to write a piece of code that populates your indices again. You may also need this code if you just play with search service and you don’t have admin interface for your data.
With Azure Search we now have a simple search service that we can use for custom data. It doesn’t matter what application we are building. We can use Azure Search from all types of applications that have access to the internet. Most of configuration can be done through the preview portal but there are still things we have to do directly through APIs. Although there are some limitations on indices we can still use the service for production environments. For smaller scenarios there is also a free version of search service available.
Published at DZone with permission of Gunnar Peipman , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.