How do you include Azure Search's @search.score as part of your custom $orderby clause

流过昼夜 提交于 2020-01-04 04:10:10

问题


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:

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.

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

I've tried the following:

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

These all result in http 502 or 400s.

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


回答1:


Edited

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

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

Original answer:

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.

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.



来源:https://stackoverflow.com/questions/34233008/how-do-you-include-azure-searchs-search-score-as-part-of-your-custom-orderby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!