Introduction
Azure AI Search provides an information retrieval service on a large amount of searchable data. For example document search, data exploration etc. You can use this service to enable powerful search capabilities within applications and solutions. Like Personalization, Insight Discovery, E-commerce Search, Healthcare Information Retrieval etc.
In Azure AI Search two term you need to know
- Indexing
- Querying
Indexing:
The purpose of this process is to loads the dataset into Azure AI Search that you created and make it searchable. The data format of an Index is in JSON. So, you need to format your data into JSON format or use and indexer to retrieve and serialize your data into JSON. Index is like a table which contains fields and their data. And each row in Index contains a new sets of records which is called document.
Querying:
You use query to search data based on a search criteria. Like retrieving a searchable content and associated document with the search terms.
Azure AI Search provides you the capability of full text search, keyword search. Also, you can use both to get most relevant results. Let's create our first search index and test some query to gain knowledge how Azure AI Search works.
Create a search index:
In order to create a search, we to follow these steps. We will be using free tier for creating a service and data source connection to sample data hosted by Microsoft on Azure Cosmos DB.
Step 01
- Go to Azure AI Search and create a resource and name it for example: FirstAISearch
- Create a search service and name it for example: firstaisearchservice. Please not that service name should be all lowercase.
Once service created successfully you will see the following successful message.
Step 02
Now go to overview menu from left hand side and select "Usage" tab to get the status of the service like indexes, indexers, and data sources you already have. Since we are using "free tier" it is limited to three indexes, three data sources, and three indexers.
Step 03
- On the "Overview" page in the top menu there is option call "Import Data"
- On Connect to your data, select the data source "Samples" from dropdown list.
- In the list of built-in samples, select hotels-sample.
- Select Next: Add cognitive skills (Optional) to continue.
- For now, select Skip to: Customize target index to continue.
Step 04
Search service refers to a schema for the built-in hotels-sample index. Follow these steps to configure the index:
- Keep as it is the Index name "hotels-sample-index" and Key field "HotelId".
- Keep values for all field attributes as it is.
- Select Next: Create an indexer to continue.
For creating the index it requires an Index name and a collection of Fields. One field must be marked as the document key to uniquely identify each document and the value is always a string.
Each field has a name, data type, and attributes that control how to use the field in the search index. Checkboxes enable or disable the following attributes:
- Retrievable: Fields returned in a query response.
- Filterable: Fields that accept a filter expression.
- Sortable: Fields that accept an orderby expression.
- Facetable: Fields used in a faceted navigation structure.
- Searchable: Fields used in full text search. Strings are searchable. Numeric fields and Boolean fields are often marked as not searchable.
Step 05
Now we will configure the executable process and indexer name. Since we are getting started keep the default settings and select "Submit"
Step 06
Go to "Indexers" from the left hand side menu and you will see that index cration status with document count in it.
Step 07:
Go to "Indexes" from the left hand side menu and you will see that index document count and storage size.
Querying with Search explorer
Step 01:
On the Search explorer tab, enter text to search on example: new york hotel near to Time's Square and in Chelsea neighborhood. And select "Search". You will see the result.
Query output in JSON be like below. You will see that output contains search terms in it.
{
"@odata.context": "https://firstaisearchservice.search.windows.net/indexes('hotels-sample-index')/$metadata#docs(*)",
"value": [
{
"@search.score": 39.42806,
"HotelId": "15",
"HotelName": "Peaceful Market Hotel & Spa",
"Description": "Book now and Save up to 30%. Central location. Steps from Empire State Building & Times Square, in Chelsea neighborhood. Brand new rooms. Impeccable service.",
"Description_fr": "Réservez dès maintenant et économisez jusqu'à 30%. Emplacement central. A quelques pas de l'Empire State Building & Times Square, dans le quartier de Chelsea. Chambres flambant neuves. Service impeccable.",
"Category": "Resort and Spa",
"Tags": [
"continental breakfast",
"restaurant",
"view"
]
}
Clean up resources
It's a good idea at the end of a project to identify whether you still need the resources you created. Resources left running can cost you money. You can delete resources individually or delete the resource group to delete the entire set of resources.
Conclusion
Overall, the purpose of using Azure AI Search is to deliver intelligent, relevant, and efficient search experiences that drive user engagement, unlock insights, and add value to applications and solutions across various industries and domains.
Top comments (0)