Skip to content

.Net: Update to latest version of Qdrant SDK. #11565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.1.0" />
<PackageVersion Include="Testcontainers.Redis" Version="4.1.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageVersion Include="Qdrant.Client" Version="1.12.0" />
<PackageVersion Include="Qdrant.Client" Version="1.13.0" />
<!-- Symbols -->
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<!-- Toolset -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.VectorData;
using Qdrant.Client.Grpc;

Expand Down Expand Up @@ -103,10 +104,28 @@ public static VectorSearchResult<TRecord> MapScoredPointToVectorSearchResult<TRe
var pointStruct = new PointStruct
{
Id = point.Id,
Vectors = point.Vectors,
Payload = { }
};

if (includeVectors)
{
pointStruct.Vectors = new();
switch (point.Vectors.VectorsOptionsCase)
{
case VectorsOutput.VectorsOptionsOneofCase.Vector:
pointStruct.Vectors.Vector = point.Vectors.Vector.Data.ToArray();
break;
case VectorsOutput.VectorsOptionsOneofCase.Vectors:
pointStruct.Vectors.Vectors_ = new();
foreach (var v in point.Vectors.Vectors.Vectors)
{
// TODO: Refactor mapper to not require pre-mapping to pointstruct to avoid this ToArray conversion.
pointStruct.Vectors.Vectors_.Vectors.Add(v.Key, v.Value.Data.ToArray());
}
break;
}
}

foreach (KeyValuePair<string, Value> payloadEntry in point.Payload)
{
pointStruct.Payload.Add(payloadEntry.Key, payloadEntry.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,28 @@ private async IAsyncEnumerable<TRecord> GetBatchByPointIdAsync<TKey>(
var pointStruct = new PointStruct
{
Id = retrievedPoint.Id,
Vectors = retrievedPoint.Vectors,
Payload = { }
};

if (includeVectors)
{
pointStruct.Vectors = new();
switch (retrievedPoint.Vectors.VectorsOptionsCase)
{
case VectorsOutput.VectorsOptionsOneofCase.Vector:
pointStruct.Vectors.Vector = retrievedPoint.Vectors.Vector.Data.ToArray();
break;
case VectorsOutput.VectorsOptionsOneofCase.Vectors:
pointStruct.Vectors.Vectors_ = new();
foreach (var v in retrievedPoint.Vectors.Vectors.Vectors)
{
// TODO: Refactor mapper to not require pre-mapping to pointstruct to avoid this ToArray conversion.
pointStruct.Vectors.Vectors_.Vectors.Add(v.Key, v.Value.Data.ToArray());
}
break;
}
}

foreach (KeyValuePair<string, Value> payloadEntry in retrievedPoint.Payload)
{
pointStruct.Payload.Add(payloadEntry.Key, payloadEntry.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ public void BuildFilterThrowsForUnknownFieldName()
[Fact]
public void MapScoredPointToVectorSearchResultMapsResults()
{
var responseVector = VectorOutput.Parser.ParseJson("{ \"data\": [1, 2, 3] }");

// Arrange.
var scoredPoint = new ScoredPoint
{
Id = 1,
Payload = { ["storage_DataField"] = "data 1" },
Vectors = new float[] { 1, 2, 3 },
Vectors = new VectorsOutput() { Vector = responseVector },
Score = 0.5f
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,23 +691,25 @@ private void SetupUpsertMock()

private static RetrievedPoint CreateRetrievedPoint<TKey>(bool hasNamedVectors, TKey recordKey)
{
var responseVector = VectorOutput.Parser.ParseJson("{ \"data\": [1, 2, 3, 4] }");

RetrievedPoint point;
if (hasNamedVectors)
{
var namedVectors = new NamedVectors();
namedVectors.Vectors.Add("vector_storage_name", new[] { 1f, 2f, 3f, 4f });
var namedVectors = new NamedVectorsOutput();
namedVectors.Vectors.Add("vector_storage_name", responseVector);
point = new RetrievedPoint()
{
Payload = { ["OriginalNameData"] = "data 1", ["data_storage_name"] = "data 1" },
Vectors = new Vectors { Vectors_ = namedVectors }
Vectors = new VectorsOutput { Vectors = namedVectors }
};
}
else
{
point = new RetrievedPoint()
{
Payload = { ["OriginalNameData"] = "data 1", ["data_storage_name"] = "data 1" },
Vectors = new[] { 1f, 2f, 3f, 4f }
Vectors = new VectorsOutput() { Vector = responseVector }
};
}

Expand All @@ -726,16 +728,18 @@ private static RetrievedPoint CreateRetrievedPoint<TKey>(bool hasNamedVectors, T

private static ScoredPoint CreateScoredPoint<TKey>(bool hasNamedVectors, TKey recordKey)
{
var responseVector = VectorOutput.Parser.ParseJson("{ \"data\": [1, 2, 3, 4] }");

ScoredPoint point;
if (hasNamedVectors)
{
var namedVectors = new NamedVectors();
namedVectors.Vectors.Add("vector_storage_name", new[] { 1f, 2f, 3f, 4f });
var namedVectors = new NamedVectorsOutput();
namedVectors.Vectors.Add("vector_storage_name", responseVector);
point = new ScoredPoint()
{
Score = 0.5f,
Payload = { ["OriginalNameData"] = "data 1", ["data_storage_name"] = "data 1" },
Vectors = new Vectors { Vectors_ = namedVectors }
Vectors = new VectorsOutput { Vectors = namedVectors }
};
}
else
Expand All @@ -744,7 +748,7 @@ private static ScoredPoint CreateScoredPoint<TKey>(bool hasNamedVectors, TKey re
{
Score = 0.5f,
Payload = { ["OriginalNameData"] = "data 1", ["data_storage_name"] = "data 1" },
Vectors = new[] { 1f, 2f, 3f, 4f }
Vectors = new VectorsOutput() { Vector = responseVector }
};
}

Expand Down
Loading