Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
OData
Note
Azure AI Search is available through the Azure portal, REST APIs, and Azure SDKs. It also underpins Foundry IQ, the managed knowledge layer that transforms enterprise content into reusable, permission-aware knowledge bases for agents in the Microsoft Foundry portal.
When you send a query to Azure AI Search without the $orderby parameter, the results that come back will be sorted in descending order by relevance score. Even when you do use $orderby, the relevance score is used to break ties by default. However, sometimes it's useful to use the relevance score as an initial sort criteria, and some other criteria as the tie-breaker. The example in this article demonstrates using the search.score function for sorting.
Note
The relevance score is computed by the relevance ranking algorithm, and the range varies depending on which algorithm you use. For more information, see Relevance and scoring in Azure AI Search.
Syntax
The syntax for search.score in $orderby is search.score(). The function search.score doesn't take any parameters. It can be used with the asc or desc sort-order specifier, just like any other clause in the $orderby parameter. It can appear anywhere in the list of sort criteria.
Example
Sort hotels in descending order by search.score and rating, and then in ascending order by distance from the given coordinates so that between two hotels with identical ratings, the closest one is listed first:
search.score() desc,rating desc,geo.distance(location, geography'POINT(-122.131577 47.678581)') asc