Azure 认知搜索中的 OData search.score 函数OData search.score function in Azure Cognitive Search

在不使用 $orderby 参数的情况下向 Azure 认知搜索发送查询时,返回的结果将按相关性评分降序排序。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. 即使你确实使用 $orderby,默认情况下,相关性评分也将用于打破平分的局面。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. search.score 函数允许你执行此操作。The search.score function allows you to do this.

语法Syntax

$orderbysearch.score 的语法为 search.score()The syntax for search.score in $orderby is search.score(). search.score 函数不接受任何参数。The function search.score does not take any parameters. 它可以与 ascdesc 排序顺序说明符一起使用,就像 $orderby 参数中的任何其他子句一样。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

search.scorerating 对酒店进行降序排序,然后按距给定坐标的距离进行升序排序,以便在两个具有相同评分的酒店中,将距离最近的酒店列在前面: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

后续步骤Next steps