search.score function in Azure Cognitive Search
When you send a query to Azure Cognitive 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 will be used to break ties by default. However, sometimes it is useful to use the relevance score as an initial sort criteria, and some other criteria as the tie-breaker. The
search.score function allows you to do this.
The syntax for
search.score in $orderby is
search.score(). The function
search.score does not take any parameters. It can be used with the
desc sort-order specifier, just like any other clause in the $orderby parameter. It can appear anywhere in the list of sort criteria.
Sort hotels in descending order by
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