AI-102 exam dumps

AI-102 practice question 379 of 493

Designing and Implementing a Microsoft Azure AI Solution. Professional level, Microsoft. Free question with the correct answer and a full explanation.

AI-102 Question 379

Single answer

You are designing a search functionality for a customer-facing application using Azure Cognitive Search. The index contains a field named 'ProductName' and another field named 'Price'. You are tasked with creating a query to retrieve all products whose names start with 'Laptop' and are priced below 1000. Additionally, the results should be sorted by price in ascending order. Which query syntax would you use?

  1. A

    search=ProductName: 'Laptop*'&$filter=Price lt 1000&$orderby=Price asc

  2. B

    search=ProductName eq 'Laptop*'&$filter=Price lt 1000&$orderby=Price asc

  3. C

    search=ProductName: 'Laptop*'&filter=Price lt 1000&orderby=Price desc

  4. D

    search=ProductName: 'Laptop'&$filter=Price lt 1000&$orderby=Price asc

Show answer and explanation

Correct answer: A

Explanation

To query an index in Azure Cognitive Search, you can use the $filter, $orderby, and search functionalities. Wildcards like '' allow flexible matching in the search expression. In this case, 'Laptop' is used to find all products whose names start with 'Laptop', '$filter=Price lt 1000' filters products with prices less than 1000, and '$orderby=Price asc' ensures the results are sorted by price in ascending order.

  • A. Correct.

    This is the correct syntax. 'Laptop*' uses a wildcard to match products starting with 'Laptop', '$filter=Price lt 1000' filters products priced below 1000, and '$orderby=Price asc' sorts the results in ascending order by price.

  • B. Incorrect.

    This is incorrect because 'ProductName eq' is used for exact matches and does not support wildcards like '*'.

  • C. Incorrect.

    This is incorrect because 'orderby=Price desc' sorts the results in descending order, not ascending as required.

  • D. Incorrect.

    This is incorrect because 'Laptop' without the wildcard '*' will only match exact product names and will not include products that start with 'Laptop'.

Timed practice exam

Take a AI-102 practice test under exam conditions

40 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam