Azure AI Solution - Hotel Search API

Hotel Search API

Question

You are tasked to search for hotels in your application based on their rating.

Your organization is already using Azure Cognitive Search for their full text search operations.

The user executes a simple text query to find top twenty hotels that offer spa and have a rating greater than four sorted in order of rating with the higher rating on the top.

Review the query below and complete it by choosing thecorrect parameter and values from the answer choices:

POST https://[service name].search.windows.net/indexes/<index name>/docs/search?api-version=2020-06-30 { ".....................................": "simple", ".....................................": "all", "search": "hotel +spa", "searchFields": "HotelName, StreetAddress, City, State, Tags", "select": "searchFields": "HotelName, StreetAddress, City, State, Tags", "top": "20", "count": "true", "orderby": "....................................." } 

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E. F.

Correct Answers: B, D and E

Here is the completed code

&lt;pre class="brush:java;"&gt;POST https://[service name].search.windows.net/indexes/&amp;lt;index name&amp;gt;/docs/search?api-version=2020-06-30

{

"queryType": "simple",

"searchMode": "all",

"search": "hotel +spa",

"searchFields": "HotelName, StreetAddress, City, State, Tags",

"select": "searchFields": "HotelName, StreetAddress, City, State, Tags",

"top": "20",

"count": "true",

"orderby": "rating desc"

}

&lt;/pre&gt;Option A is incorrect because filter is the parameter used for OData filter expressions.

Given the completed JSON code in the explanation above, filter is not the correct parameter.

Option B is correct because the “rating desc” is used to sort the hotels in descending order based on their ratings.

Given the completed JSON code in the explanation above, “rating desc” is the correct value for orderby parameter.

Option C is incorrect because the facet parameter is used when you have a field to facet by, for example, query based on brand or category.

Given the completed JSON code in the explanation above, facet is not the correct parameter.

Option D is correct because the searchMode parameter is used to search for any or all documents in the search to match and count the documents.

Given the completed JSON code in the explanation above, searchMode is the correct parameter for value “all”.

Option E is correct because the queryType in the requirements is simple.

For a full text search you would need to maintain the value as “full” for the parameter queryType.

Given the completed JSON code in the explanation above, queryType is the correct parameter.

Option F is incorrect because the parameter values for scoring parameters such as geographic locations.

Given the completed JSON code in the explanation above, it is not the correct parameter.

Reference:

To learn more about searching documents in Azure Cognitive Search, use the link given below:

To complete the query to search for hotels based on their rating, we need to fill in the "orderby" parameter. The "orderby" parameter is used to specify the field to sort the results by and the sorting order. The correct answer for the "orderby" parameter is B. rating desc.

The complete query to search for top twenty hotels that offer spa and have a rating greater than four sorted in order of rating with the higher rating on the top using Azure Cognitive Search is as follows:

perl
POST https://[service name].search.windows.net/indexes/<index name>/docs/search?api-version=2020-06-30 { "search": "hotel +spa", "searchFields": "HotelName, StreetAddress, City, State, Tags", "select": "searchFields": "HotelName, StreetAddress, City, State, Tags", "top": "20", "count": "true", "orderby": "rating desc" }

Here, the "search" parameter specifies the query text to search for hotels that offer spa. The "searchFields" parameter specifies the fields to search in for the query text. The "select" parameter specifies the fields to retrieve in the search results. The "top" parameter specifies the maximum number of search results to return. The "count" parameter specifies whether to return the total count of search results. Finally, the "orderby" parameter specifies the field to sort the search results by and the sorting order. In this case, we want to sort by the "rating" field in descending order, which means the hotels with the highest rating will appear at the top of the search results.