Skip to content

[BUG] MergeOrUploadDocuments() fails to serialize vectors declared using annotations #43414

Open
@marianotn

Description

@marianotn

Library name and version

Azure.Search.Documents 11.6.0.0

Describe the bug

The problem is when I declare the vector field using annotations.

if I declare it as

[VectorSearchField(VectorSearchDimensions = 1536, VectorSearchProfileName = "my-vector-profile")]
public ReadOnlyMemory<float> DisplayNameVector { get; set; }

it gives the error in the description.

If instead I declare it inline, it works:

new SearchField("DisplayNameVector", SearchFieldDataType.Collection(SearchFieldDataType.Single))
{
IsSearchable = true,
VectorSearchDimensions = m_modelDimensions,
VectorSearchProfileName = m_vectorSearchHnswProfile,
}

ields that have their vector field counterpart (like string DisplayName, ReadOnlyMemory DisplayNameVector) break when pushing this document through calling searchClient.MergeOrUploadDocuments(data), I'm getting errors like below.

Azure.RequestFailedException
HResult=0x80131500
Message=The request is invalid. Details: A node of type 'StartArray' was read from the JSON reader when trying to read the contents of the property 'DisplayNameVector'; however, a 'StartObject' node or 'PrimitiveValue' node with null value was expected.
Status: 400 (Bad Request)

Content:
{"error":{"code":"","message":"The request is invalid. Details: A node of type 'StartArray' was read from the JSON reader when trying to read the contents of the property 'DisplayNameVector'; however, a 'StartObject' node or 'PrimitiveValue' node with null value was expected."}}

Headers:
Content-Language: REDACTED
Strict-Transport-Security: REDACTED
Preference-Applied: REDACTED
client-request-id: 3545775b-17e8-44b1-9e01-109179d0af93
x-ms-client-request-id: 3545775b-17e8-44b1-9e01-109179d0af93
request-id: 3545775b-17e8-44b1-9e01-109179d0af93
elapsed-time: 292
Content-Length: 279
Content-Type: application/json; charset=utf-8
Date: Thu, 28 Mar 2024 21:16:25 GMT
Server: Microsoft-IIS/10.0

Source=Azure.Search.Documents
StackTrace:
at Azure.Search.Documents.SearchClient.d__501.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Search.Documents.SearchClient.IndexDocuments[T](IndexDocumentsBatch1 batch, IndexDocumentsOptions options, CancellationToken cancellationToken)
at Azure.Search.Documents.SearchClient.MergeOrUploadDocuments[T](IEnumerable1 documents, IndexDocumentsOptions options, CancellationToken cancellationToken) at Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.ExtensionMethods.Ingest[T](IEnumerable1 data, SearchClient searchClient) in Q:\Repos\Shared\Sql\CloudBI\AS\src\PowerBI\PowerBIArtifactIndex\StorageClients\AzureSearchClient\ExtensionMethods.cs:line 51
at Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.AzureSearchClient.IngestData[T](IEnumerable`1 data) in Q:\Repos\Shared\Sql\CloudBI\AS\src\PowerBI\PowerBIArtifactIndex\StorageClients\AzureSearchClient\AzureSearchClient.cs:line 426

This exception was originally thrown at this call stack:
[External Code]
Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.ExtensionMethods.Ingest(System.Collections.Generic.IEnumerable, Azure.Search.Documents.SearchClient) in ExtensionMethods.cs
Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.AzureSearchClient.IngestData(System.Collections.Generic.IEnumerable) in AzureSearchClient.cs

Expected behavior

To push the parse the vector's data and push to its index.

Actual behavior

Azure.RequestFailedException
HResult=0x80131500
Message=The request is invalid. Details: A node of type 'StartArray' was read from the JSON reader when trying to read the contents of the property 'DisplayNameVector'; however, a 'StartObject' node or 'PrimitiveValue' node with null value was expected.
Status: 400 (Bad Request)

Content:
{"error":{"code":"","message":"The request is invalid. Details: A node of type 'StartArray' was read from the JSON reader when trying to read the contents of the property 'DisplayNameVector'; however, a 'StartObject' node or 'PrimitiveValue' node with null value was expected."}}

Headers:
Content-Language: REDACTED
Strict-Transport-Security: REDACTED
Preference-Applied: REDACTED
client-request-id: 3545775b-17e8-44b1-9e01-109179d0af93
x-ms-client-request-id: 3545775b-17e8-44b1-9e01-109179d0af93
request-id: 3545775b-17e8-44b1-9e01-109179d0af93
elapsed-time: 292
Content-Length: 279
Content-Type: application/json; charset=utf-8
Date: Thu, 28 Mar 2024 21:16:25 GMT
Server: Microsoft-IIS/10.0

Source=Azure.Search.Documents
StackTrace:
at Azure.Search.Documents.SearchClient.d__501.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Search.Documents.SearchClient.IndexDocuments[T](IndexDocumentsBatch1 batch, IndexDocumentsOptions options, CancellationToken cancellationToken)
at Azure.Search.Documents.SearchClient.MergeOrUploadDocuments[T](IEnumerable1 documents, IndexDocumentsOptions options, CancellationToken cancellationToken) at Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.ExtensionMethods.Ingest[T](IEnumerable1 data, SearchClient searchClient) in Q:\Repos\Shared\Sql\CloudBI\AS\src\PowerBI\PowerBIArtifactIndex\StorageClients\AzureSearchClient\ExtensionMethods.cs:line 51
at Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.AzureSearchClient.IngestData[T](IEnumerable`1 data) in Q:\Repos\Shared\Sql\CloudBI\AS\src\PowerBI\PowerBIArtifactIndex\StorageClients\AzureSearchClient\AzureSearchClient.cs:line 426

This exception was originally thrown at this call stack:
[External Code]
Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.ExtensionMethods.Ingest(System.Collections.Generic.IEnumerable, Azure.Search.Documents.SearchClient) in ExtensionMethods.cs
Microsoft.PowerBI.ArtifactIndex.AzureSearchClient.AzureSearchClient.IngestData(System.Collections.Generic.IEnumerable) in AzureSearchClient.cs

Reproduction Steps

Declaring properties like:

[VectorSearchField(VectorSearchDimensions = 1536, VectorSearchProfileName = "my-vector-profile")]
public ReadOnlyMemory<float> DisplayNameVector { get; set; }

And use FieldBuilder() to create the list of fields.

Using Azure.OpenAI client, get the embeddings for DisplayName.
var response = openAIClient.GetEmbeddings(new EmbeddingsOptions("my-text-embedding-ada-002", [text]));

data.displayNameVector = response.Value.Data[0].Embedding;

And push:

var results = searchClient.MergeOrUploadDocuments(data);

Environment

Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.9.3

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Searchcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions