Azure AI Search Index gives a different answer in 'Search Explorer' & REST API response for same query

Viswavaageesh Chandramouli 25 Reputation points
2024-09-05T14:36:39.18+00:00

For the search query below, there is a discrepancy between the results in the Search explored in Azure portal to the REST API response.

search=&$orderby=MaxUnits desc&$select=&$top=5

The answer in the Search Explorer:
User's image

While, for REST API query:

GET {{baseUrl}}/indexes/{{indexName}}/docs?api-version=2024-07-01&search=*&$orderby=MaxUnits desc&$select=*&$top=5Content-Type: application/jsonapi-key: {{apiKey}}

The response is:
User's image

Really appreciate your help here. @navba-MSFT

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 39,106 Reputation points Volunteer Moderator
    2025-10-20T19:49:01.7466667+00:00

    Hello !

    Thank you for posting on Microsoft Learn Q&A.

    With search=* every document gets the same relevance score (1.0). If many rows share the same MaxUnits value, the service is free to break ties in any order.

    Search Explorer and your REST call can therefore return different documents at the top even with the same query.

    Make the ordering deterministic by adding a unique tiebreaker and replace ID with your actual key field :

    GET /indexes/{indexName}/docs?
      api-version=2024-07-01&
      search=* &
      $orderby=MaxUnits desc, ID asc &
      $select=* &
      $top=5
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.