Skip to content

[BUG] Azure Search result deserialization cannot handle document debug info #46958

Open
@mattgotteiner

Description

@mattgotteiner

Library name and version

Azure.Search.Documents 11.7.0-beta.1

Describe the bug

Attempting to use QueryDebugMode results in the following error:

System.InvalidOperationException
  HResult=0x80131509
  Message=The requested operation requires an element of type 'Array', but the target element has type 'Object'.
  Source=System.Text.Json
  StackTrace:
   at System.Text.Json.ThrowHelper.ThrowJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType)
   at System.Text.Json.JsonElement.EnumerateArray()
   at Azure.Search.Documents.Models.SearchResult`1.<DeserializeAsync>d__21.MoveNext()
   at Azure.Search.Documents.Models.SearchResults`1.<DeserializeAsync>d__37.MoveNext()
   at Azure.Search.Documents.SearchClient.<SearchInternal>d__41`1.MoveNext()
   at Azure.Search.Documents.SearchClient.<SearchInternal>d__40`1.MoveNext()
   at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted[T](Task`1 task)
   at Azure.Search.Documents.SearchClient.Search[T](String searchText, SearchOptions options, CancellationToken cancellationToken)
   at Program.<Main>$(String[] args) in C:\Users\magottei\source\repos\minrepro\Program.cs:line 7

Expected behavior

  1. debug is a parameter on the search request. It should not be required to set SemanticSearch on SearchOptions to use this property. Here's a sample REST request demonstrating this:
{
  "search": "*",
  "top": 1,
  "vectorQueries": [
    {
      "kind": "text",
      "text": "test",
      "fields": "contentVector"
    }
  ],
  "debug": "vector"
}
  1. The "vector" value of QueryDebugMode is missing despite being present in the swagger. It should not be required to create a new instance of QueryDebugMode to use this value
  2. DocumentDebugInfo is deserialized as an array when it should be treated as an object. Here's a sample REST response corresponding to the query in the repro below:
{
  "value": [
    {
      "@search.score": 0.61361045,
      "@search.documentDebugInfo": {
        "semantic": null,
        "vectors": {
          "subscores": {
            "documentBoost": null,
            "text": null,
            "vectors": [
              {
                "contentVector": {
                  "searchScore": 0.61361045,
                  "vectorSimilarity": 0.37030154880836874
                }
              }
            ]
          }
        }
      },
....

Actual behavior

The repro crashes before the search results are fully deserialized, preventing use of debug property

Reproduction Steps

  1. Use the sample to populate a sample index with vector values
  2. Run the following C# code to reproduce the bug using the index from the sample above:
using Azure.Identity;
using Azure.Search.Documents;
using Azure.Search.Documents.Models;

var client = new SearchClient(new Uri("https://service.search.windows.net"), "test-dotnet-vector-sample", new DefaultAzureCredential());

client.Search<SearchDocument>(
    searchText: "*",
    new SearchOptions
    {
        Size = 1,
        VectorSearch = new VectorSearchOptions
        {
            Queries =
            {
                new VectorizableTextQuery("test") { Fields = { "contentVector" } }
            }
        },
        SemanticSearch = new SemanticSearchOptions { Debug = new QueryDebugMode("vector") }
    });

Environment

.NET SDK:
Version: 8.0.403
Commit: c64aa40a71
Workload version: 8.0.400-manifests.e99c892e
MSBuild version: 17.11.9+a69bbaaf5

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.403\

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Searchneeds-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions