In order to improve query productivity, you decide to use suggester as offered in Azure Cognitive search.
You enable suggestions on “city” as the key field.
The response will provide users with matching documents.
Review the code snippet given below and complete it by choosing the most appropriate query parameter to limit the search to 5 cities:
POST /indexes/city/docs/suggest?api-version=2020-06-30 { "search": "new", "............................": 5, "suggesterName": "suggester1" }
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer: B.
Option A is incorrect.
A select parameter is used when you need to include additional fields for differentiation.
Hence it is not the correct parameter of choice here.
Option B is correct.
Here is the completed code snippet.
Parameter top is used for control search results to 5 cities.
<pre>POST /indexes/city/docs/suggest?api-version=2020-06-30
{
"search": "new",
"top": 5,
"suggesterName": "suggester1"
}
</pre>
Option C is incorrect.
Filter parameter uses filterable fields to provide results.
Given the scenario, it is not an appropriate parameter.
Option D is incorrect.
A fuzzy parameter requires a boolean value.
It helps find missing or substituted characters in the search text.
Given the scenario, it is not an appropriate parameter choice.
To learn more about autocomplete and suggestions in Azure cognitive search, use the link given below:
The most appropriate query parameter to limit the search to 5 cities in the given code snippet is "top."
The "top" parameter in Azure Cognitive Search is used to specify the maximum number of search results to be returned in a single page. In this case, the query parameter "top" will limit the search to only 5 cities.
The complete code snippet to enable suggester with the "top" query parameter would be as follows:
bashPOST /indexes/city/docs/suggest?api-version=2020-06-30 { "search": "new", "top": 5, "suggesterName": "suggester1" }
In the above code snippet, "search" is the query text that the user types in the search box, and "suggesterName" is the name of the suggester. The "top" parameter is set to 5 to limit the search results to 5 cities.
The "select" parameter is used to select specific fields to return from the search results, and the "filter" parameter is used to filter the search results based on a specific condition. The "fuzzy" parameter is used to enable fuzzy matching in the search results.
In summary, the "top" parameter is used to limit the search results to a specific number, and in this case, it is used to limit the search to 5 cities.