AI-102 Question 380
Single answerYou are developing an Azure Cognitive Search solution for an e-commerce platform. The platform allows users to search for products using various filters, such as price range, product category, and keywords. You need to create a query to retrieve all products in the 'Electronics' category with a price less than $500, sorted by price in ascending order. Which of the following queries achieves this?
- A
search=*&$filter=category eq 'Electronics' and price lt 500&$orderby=price asc
- B
search=*&$filter=category eq 'Electronics' and price gt 500&$orderby=price desc
- C
search=*&$filter=category eq 'Electronics' and price lt 500&$orderby=price desc
- D
search=*&$filter=category eq 'Electronics'&$orderby=price asc
Show answer and explanation
Correct answer: A
Explanation
The correct query must include the appropriate filter for the 'Electronics' category and a price less than $500, as well as sort the results by price in ascending order. Only the first option meets all these criteria.
- A. Correct.
This query correctly applies the filter for the 'Electronics' category and price less than $500, and sorts the results by price in ascending order. This fulfills all the requirements in the scenario.
- B. Incorrect.
This query filters for the 'Electronics' category but uses a filter for price greater than $500 and sorts in descending order, which does not meet the conditions specified.
- C. Incorrect.
This query filters for the 'Electronics' category and price less than $500 but sorts in descending order instead of ascending order, which does not meet the sorting requirement.
- D. Incorrect.
This query filters for the 'Electronics' category but does not filter for price less than $500. It sorts by price in ascending order, but it does not fully meet the requirements.