Azure Search allows you to create a service making your own data searchable, in much the same way that public search engines like Google and Bing make data on the Internet searchable.
In this article, I will show how to use a REST API exposed by the Azure Search service to return indexed results, based on search criteria.
You can do some limited searching using the Azure portal. Navigate to the Azure portal and login; then, navigate to the Azure Search service, as shown in Fig. 1.
Click the [Search explorer] button (Fig. 2) to display the "Search explorer" blade, as shown in Fig. 3.
At the "Query string" field, you can enter a search term and click the [Search] button to return all the data (in JSON format) that matches the search term in any field you marked "FILTERABLE" in your index. Clicking the [Search] button issues an HTTP GET against the Search service's REST API. The results are shown in Fig. 4.
You have more flexibility calling the REST API with a POST request. This is not possible through the portal; but you can use a tool like Postman to make these requests.
The URL to which you POST can be found on the Azure service's "Overview" tab, as shown in in Fig. 5.
The URL takes the form:
You will also need the Query key. You can find the Query key by opening the Azure Search service's "Keys" blade (Fig. 6) and clicking "Manage query keys" to display the "Manage query keys" blade, as shown in Fig. 7.
To test POSTing to the REST API, open Postman and open a new tab, as shown in Fig. 8.
At the Verb dropdown, select "POST".
At the "Request URL" field, paste in the URL. This will be the URL copied from the "Overview" tab, followed by "/indexes/
This is shown in Fig. 9.
Select the "Headers" tab, as shown in Fig. 10.
Enter the following 2 key/value pairs:
Key="api-key"; value=the Query key copied from the service.
These are shown in Fig. 11.
Select the "Body" tab to enter search parameters, as shown in Fig. 12.
The example shown
"filter": "state eq 'IL'",
"orderby": "presentationDate desc"
instructs the API to select all the fields' to filter the data, returning only those in which the "state" field equals "IL"; and sort the results in descending order by presentation date.
The results are shown in Fig. 13.
In this article, you learned how to use the REST API to access an Azure Search service.
Click the [Send] button to POST to the API.