- Even if we provide only keywords, we can still search the information.
- Even if the spelling of the searched words is not correct, search engine still provides right search results.
- Geo-search where you can search like ‘pizza store near me’ and it will return all nearby pizza stores
- Faceted search – where you can specify filters that you are only looking for images, or books, and search engine returns only related results.
Now a days, similar search functionalities are provided in phone apps or web sites. These search features work on the data which is local to your web site.
Imagine that you have to implement a “min-search-engine” like Google or Bing for your phone app or web site which has all of the capabilities mentioned above. We all will agree that it would be very complex and time consuming task.
What if out of the box solution is available ?
Let’s see what is Azure Search ?
Azure search is a search-as-a-service solution on Azure platform.
Azure search provides APIs and tools to developers for adding a rich search experience over private, heterogeneous content in web, mobile, and enterprise applications.
All of the functionality in Azure search is exposed through REST APIs and .Net SDK. All the internal implementation details of Azure search are hidden from the applications / developers which consume these APIs.
Best part is, the Azure search service runs in the cloud, hence infrastructure and availability of this service are managed by Microsoft.
And, how does it work ?
Let’s quickly understand how a search engine works. Every search engine has below important components. Again, this is not purpose of this article, but to understand how the Azure search works, it would be good to know.
- Crawler – crawler is a component which goes through all the web sites and every web page’s keywords. It starts with few web pages and then it goes through links specified in all those web pages to get next set of web sites. But doing this is not enough. All the information obtained by Crawler should be organized so that it can be served to end users.
- Index – This the place where all the information is stored sorted and organized.
- Queries – these are executed against index to get the search results. A query is nothing but the words entered by user for initiating the search.
Now we are ready to understand how to consume Azure search:
Provisioning Azure Search Service
You can create Azure search instance using Azure Portal or Azure Resource Manager template. You can scale the search service:
- Increase partitions to grow storage of documents
- Increase replicas to grow capacity to handle heavy query loads
If you have Azure subscription, you can create a free Azure search service. Please note that free tier does not support scaling. If you do not have subscription, then you can create free account on Azure.
Before you upload searchable content, it is very important to define the index schema. Index schema is like a database table which can hold data and it can also accept queries to get the data.
Defining schema is art. You will have to completely understand how the information would be searched by end users.
You define the index schema to map to reflect the structure of the documents you wish to search, similar to fields in a database.
Load Index Data
After you define the index, you are ready to upload the contents. There are two models you can select – either Push model or Pull model.
In push model, you can send index information using REST API or .NET SDK APIs. You can push data from virtually any dataset including plain JSON format.
In pull model, the data is retrieved from the external data source. This process is stream-lined using something called as “indexers“. These indexers automate the whole concept of data ingestion. This capability includes connecting to data store, reading data, serializing data, etc.
After populating an index, you can issue search queries to your service endpoint using simple HTTP requests with REST API or the .NET SDK.
I hope this article has provided enough information to get started on Azure search. Please do comment and let me know your thoughts.