Share via

Relevance score horribly low using @azure/search vs using search explorer in Portal

dude95 40 Reputation points
2025-04-15T17:38:39.53+00:00

I'm getting totally different results with searching using the search explorer in the Portal and in my bot. Here is the portal search explorer query

{
    "search": "SuccessFactors 2025 date",
    "count": true,
    "queryType": "semantic",
    "semanticConfiguration": "default", // <<< USE YOUR ACTUAL CONFIG NAME
    "queryLanguage": "en-us", 
    "captions": "extractive", 
    "answers": "extractive|count-3", 
    "select": "docId,docTitle,description,filename,fileUrl,lastmodified,chunkindex,totalChuncks", 
    "top": 10 
    // Vector search is implicitly included and configured via the semanticConfiguration
}

Here is partial results

{
  "@odata.context": "https://zyptai-s11-search.search.windows.net/indexes('sharepointblobindx')/$metadata#docs(*)",
  "@odata.count": 63,
  "@search.answers": [
    {
      "key": "01ICKOLJXIBDIQTU2WJVEJ275LQA6B7OTA-44",
      "text": "It's got ... Yeah, the the goal would be to stand up everybody at S...",
      "score": 0.9900000095367432
    },
    {
      "key": "01ICKOLJR343RCVRR7WJGL7AGOZYBCZXHX-1",
      "text": "It's got ... Yeah, the the goal would be to stand up everybody at SuccessFactors ...",
      "score": 0.9850000143051147
    },

Code from my webbot

      const searchOptions: SearchOptions<SearchDocument> = {
        // Select fields based on what's needed and what portal test selected
        select: [
          "description",
          "chunkindex",
          "filename",
          "fileUrl",
          "docId",
          "docTitle",
          "lastmodified",
          "totalChuncks"
        ],
        top: MAX_RESULTS,
        // Enable Semantic Reranking features
        queryType: "semantic" as const,
        // Use the semantic search options object:
        semanticSearchOptions: {
          configurationName: "my-semantic-config",
          answers: { 
            answerType: "extractive", 
            count: 3
          },
          captions: { 
            captionType: "extractive", 
            highlight: true 
          }
        },
        // Vector search configuration
        vectorSearchOptions: {
          queries: [{
            kind: "vector" as const,
            fields: ["descriptionVector"], // Field containing the vector embeddings
            kNearestNeighborsCount: K_NEAREST_NEIGHBORS, // How many vector results to initially find
            vector: queryVector, // The query vector itself
          }]
        },
        searchMode: "any" as const, // Use 'any' for OR logic on keywords
        includeTotalCount: true // Request the total count of results
      };

The results are 10x worse - can't really recognize anything of value:
[2025-04-15T13:09:20.037Z] INFO: [1] File: Fake meeting template - just a little discussion.docx, RerankerScore: N/A, HybridScore: 0.0315, Chunk: 2

[2025-04-15T13:09:20.044Z] INFO: [2] File: Phase 2 Planning Summit Day 1 (1) (1) (1).pdf, RerankerScore: N/A, HybridScore: 0.0308, Chunk: 54

[2025-04-15T13:09:20.045Z] INFO: [3] File: Phase 2 Planning Summit Day 1 (1) (1) (1).pdf, RerankerScore: N/A, HybridScore: 0.0255, Chunk: 56

I feel like the frontend code should replicated the Portal call. Even ChatGPT thinks they are the same. Anyone have an idea of what went wrong?

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.


Answer accepted by question author

  1. Anonymous
    2025-04-16T21:38:18.2766667+00:00

    Hi dude95,

    You are using the @azure/search-documents SDK with semantic search, but the reranker score (@search.rerankerScore) always shows as N/A in your bot or web client, even after disabling vector search. This causes the system to rely on the hybrid score, which works sometimes but misses relevant answers in complex queries.

    The @azure/search-documents SDK (v12.1.0) has a known issue where it doesn't always return the @search.rerankerScore, even with correct semantic search setup. However, the Azure Portal Search Explorer works fine and returns the reranker score since it fully supports the semantic pipeline.

    • Use the REST API directly for testing reranker scores. This avoids SDK issues and shows raw results, including fields like @search.rerankerScore, @search.answers, and @search.captions.
    • https://learn.microsoft.com/en-us/azure/search/semantic-how-to-query-request?tabs=portal-query#set-up-the-query
    • If you prefer using the SDK, check if a newer version of @azure/search-documents (after v12.1.0) fixes the issue and correctly returns the @search.rerankerScore.
    • As a workaround, keep using the hybrid score fallback with a smart threshold, but note it's less accurate than semantic reranking.

    Kindly refer to this document to understand how ranking is scored.

    https://learn.microsoft.com/en-us/azure/search/semantic-search-overview#how-ranking-is-scored

    Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    Let me know if you have any further Queries.

    Was this answer helpful?

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Azar 31,715 Reputation points MVP Volunteer Moderator
    2025-04-15T17:46:08.28+00:00

    Hi there dude95

    Thanks for using QandA platform

    i see In the Portal you’re using "default", but in code it’s "my-semantic-config". Make sure both point to the same setup. the Portal likely runs hybrid automatically. In your code, adding vectorSearchOptions manually might bypass reranking. Try removing it and test again.

    Your logs show RerankerScore: N/A. That’s a red flag—semantic reranking probably isn’t even running. Could be field mismatches or config issues.

    TL;DR: Try removing vector search, match the semantic config name exactly, and check if reranker kicks in]

    If this helps kindly accept the answer thanks much.

    Was this answer helpful?

    1 person found this answer helpful.
    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.