azure search sort and filter by score

2019-03-01 06:46发布

问题:

I want to know how to filter and order the results by score with azure search.

I tried :

https://domaine.net/indexes/indexName/docs?search=TEST$orderby=@search.score%20desc&$count=true

Return :

object(stdClass)#322 (1) {
  ["error"]=>
  object(stdClass)#323 (2) {
    ["code"]=>
    string(0) ""
    ["message"]=>
    string(96) "Invalid expression: Syntax error at position 8 in '@search.score asc'.
Parameter name: $orderby"
  }
}

回答1:

Results are sorted by score (descending) by default. If you sort by other criteria, score is used to break ties. If you want to sort by score explicitly, you can use the search.score() function in the $orderby parameter. It is documented here.

It's not currently possible to filter by score. Since score varies as a function of not only the query but also the data corpus, I would be curious to understand your scenario better for filtering based on a score number.