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
Foundry IQ (Azure AI Search) provides direct indexing and query APIs alongside higher-level knowledge source and knowledge base APIs for managed retrieval. Use the Azure portal, REST APIs, or Azure SDKs to configure these capabilities, or connect agents to knowledge bases in the Microsoft Foundry portal.
When you send a query to Foundry IQ (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 Foundry IQ.
Syntax
The syntax for search.score in $orderby is search.score(). The function search.score doesn't take any parameters. For full-text queries, you can use it 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 relevance scores and ratings, the closest one is listed first:
search.score() desc,rating desc,geo.distance(location, geography'POINT(-122.131577 47.678581)') asc
Limitations
You can't use search.score() in $orderby for pure vector or hybrid queries. The service rejects these requests with an HTTP 400 InvalidRequestParameter error. To correct the request, remove search.score() from $orderby.