如何将Azure Search的@ search.score包含在自定义$ orderby子句中 [英] How do you include Azure Search's @search.score as part of your custom $orderby clause

查看:110
本文介绍了如何将Azure Search的@ search.score包含在自定义$ orderby子句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此页面,Azure搜索结果的默认排序方式是按Azure自己的得分(降序).但是,您可以提供一个$ orderby子句,该子句定义为:

According to this page, the default sort of Azure Search results is by Azure's own score (descending). However, you can supply an $orderby clause, which is defined as:

以逗号分隔的表达式列表,用于对结果进行排序.每个 表达式可以是字段名称,也可以是对geo.distance()的调用 功能.

A list of comma-separated expressions to sort the results by. Each expression can be either a field name or a call to the geo.distance() function.

我想按Azure的@ search.score desc,MyFieldOne,MyFieldTwo进行排序.但是,我无法弄清楚如何引用@ search.score字段".

I want to sort by Azure's @search.score desc, MyFieldOne, MyFieldTwo. But, I cannot figure out how to reference the @search.score "field."

我尝试了以下操作:

$orderby=search.score+desc,MyFieldOne,MyFieldTwo
$orderby=@search.score+desc,MyFieldOne,MyFieldTwo
$orderby=%40search.score+desc,MyFieldOne,MyFieldTwo

所有这些都导致http 502或400s.

These all result in http 502 or 400s.

如何在请求中引用@ search.score值?

How do I reference the @search.score value in my request?

推荐答案

已编辑

Azure Search现在支持使用新的search.score() OData函数按分数排序.例如,要按分数然后按名称排序,请执行以下操作:

Azure Search now supports sorting by score using the new search.score() OData function. For example, to sort by score then by name, do this:

$orderby=search.score() desc, name asc

API参考已更新,以包括新的search.score()函数.

The API reference has been updated to include the new search.score() function.

原始答案:

Azure Search当前不允许您在orderby子句中引用分数.请对此 UserVoice建议进行投票帮助我们确定这项工作的优先级.

Azure Search currently doesn't let you refer to the score in an orderby clause. Please vote for this UserVoice suggestion to help us prioritize this work.

但是,请注意,两个文档的得分很少会相同,因此在$oderby=@search.score之后使用平局决胜局的情况很少出现,并且在大多数情况下,排序顺序将等效于按等级排序,即默认情况下会发生什么.

Note, however, that score will rarely be the same for two documents, so using tie-breakers after the $oderby=@search.score will rarely come into play, and in most cases the sort order will be equivalent to sorting by rank, which is what happens by default.

这篇关于如何将Azure Search的@ search.score包含在自定义$ orderby子句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆