Skip to content
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
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageProjectUrl>https://github.com/qdrant/qdrant-dotnet</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/qdrant/qdrant-dotnet/releases</PackageReleaseNotes>
<PackageTags>qdrant, database, vector, search</PackageTags>
<QdrantVersion>v1.17.0</QdrantVersion>
<QdrantVersion>v1.18.0</QdrantVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -29,4 +29,4 @@
<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="all"/>
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Bullseye" Version="6.0.0" />
<PackageReference Include="SimpleExec" Version="12.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="SharpCompress" Version="0.39.0" />
<PackageReference Include="SharpCompress" Version="0.48.0" />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix a known moderate vulnerability.

</ItemGroup>

</Project>
7 changes: 3 additions & 4 deletions build/Main.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.IO.Compression;
using System.Net.Http.Headers;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Bullseye;
using SharpCompress.Common;
using SharpCompress.Readers;
using static BuildTargets;
using static Bullseye.Targets;
Expand Down Expand Up @@ -87,13 +87,12 @@

var response = await client.GetAsync(url);
await using var stream = await response.Content.ReadAsStreamAsync();
await using var gzip = new GZipStream(stream, CompressionMode.Decompress);
var reader = ReaderFactory.Open(gzip);
using var reader = ReaderFactory.OpenReader(stream);
while (reader.MoveToNextEntry())
{
var entry = reader.Entry;
if (!entry.IsDirectory && protoFileRegex.IsMatch(entry.Key!) && !privateProtoFileRegex.IsMatch(entry.Key!))
reader.WriteEntryToDirectory(protosTagDir);
reader.WriteEntryToDirectory(protosTagDir, new ExtractionOptions { ExtractFullPath = false, Overwrite = true });
}

{
Expand Down
22 changes: 22 additions & 0 deletions src/Qdrant.Client/IQdrantClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,28 @@ Task<UpdateResult> DeletePayloadIndexAsync(
WriteOrderingType? ordering = null,
CancellationToken cancellationToken = default);

/// <summary>
/// Creates a new named vector on a collection.
/// </summary>
/// <param name="request">The create vector name request.</param>
/// <param name="cancellationToken">
/// The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.
/// </param>
Task<UpdateResult> CreateVectorNameAsync(
CreateVectorNameRequest request,
CancellationToken cancellationToken = default);

/// <summary>
/// Deletes a named vector from a collection.
/// </summary>
/// <param name="request">The delete vector name request.</param>
/// <param name="cancellationToken">
/// The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.
/// </param>
Task<UpdateResult> DeleteVectorNameAsync(
DeleteVectorNameRequest request,
CancellationToken cancellationToken = default);

/// <summary>
/// Retrieves closest points based on vector similarity and the given filtering conditions.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Qdrant.Client/LoggingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ internal static partial class LoggingExtensions
[LoggerMessage(3014, LogLevel.Debug, "Delete payload field index in '{collection}'")]
public static partial void DeletePayloadIndex(this ILogger logger, string collection);

[LoggerMessage(3032, LogLevel.Debug, "Create vector name '{vectorName}' in '{collection}'")]
public static partial void CreateVectorName(this ILogger logger, string collection, string vectorName);

[LoggerMessage(3033, LogLevel.Debug, "Delete vector name '{vectorName}' in '{collection}'")]
public static partial void DeleteVectorName(this ILogger logger, string collection, string vectorName);

[LoggerMessage(3015, LogLevel.Debug, "Search on '{collection}'")]
public static partial void Search(this ILogger logger, string collection);

Expand Down
52 changes: 50 additions & 2 deletions src/Qdrant.Client/QdrantClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1444,8 +1444,6 @@ public async Task<UpdateResult> UpsertAsync(
if (updateFilter is not null)
request.UpdateFilter = updateFilter;

_logger.Upsert(collectionName, points.Count);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate.

The call below logs the same.


return await UpsertAsync(request, cancellationToken).ConfigureAwait(false);
}

Expand Down Expand Up @@ -3010,6 +3008,56 @@ public async Task<UpdateResult> DeletePayloadIndexAsync(
}
}

/// <inheritdoc />
public async Task<UpdateResult> CreateVectorNameAsync(
CreateVectorNameRequest request,
CancellationToken cancellationToken = default)
{
_logger.CreateVectorName(request.CollectionName, request.VectorName);

try
{
var response = await _pointsClient.CreateVectorNameAsync(
request,
deadline: _grpcTimeout == default ? null : DateTime.UtcNow.Add(_grpcTimeout),
cancellationToken: cancellationToken)
.ConfigureAwait(false);

return response.Result;
}
catch (Exception e)
{
_logger.OperationFailed(nameof(LoggingExtensions.CreateVectorName), e);

throw;
}
}

/// <inheritdoc />
public async Task<UpdateResult> DeleteVectorNameAsync(
DeleteVectorNameRequest request,
CancellationToken cancellationToken = default)
{
_logger.DeleteVectorName(request.CollectionName, request.VectorName);

try
{
var response = await _pointsClient.DeleteVectorNameAsync(
request,
deadline: _grpcTimeout == default ? null : DateTime.UtcNow.Add(_grpcTimeout),
cancellationToken: cancellationToken)
.ConfigureAwait(false);

return response.Result;
}
catch (Exception e)
{
_logger.OperationFailed(nameof(LoggingExtensions.DeleteVectorName), e);

throw;
}
}

/// <summary>
/// Retrieves closest points based on vector similarity and the given filtering conditions.
/// </summary>
Expand Down
35 changes: 35 additions & 0 deletions tests/Qdrant.Client.Tests/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,41 @@ public async Task DeleteAlias()
Assert.Empty(await _client.ListCollectionAliasesAsync("collection_1"));
}

[Fact]
public async Task CreateAndDeleteVector()
{
const string collectionName = "collection_1";

await _client.CreateCollectionAsync(collectionName, new VectorParamsMap
{
Map = { ["vector_1"] = new() { Size = 4, Distance = Distance.Dot } }
});

await _client.CreateVectorNameAsync(new()
{
CollectionName = collectionName,
VectorName = "vector_2",
Wait = true,
DenseConfig = new() { Size = 8, Distance = Distance.Cosine }
});

var info = await _client.GetCollectionInfoAsync(collectionName);
var vectors = info.Config.Params.VectorsConfig.ParamsMap.Map;
vectors.Should().HaveCount(2).And.ContainKeys("vector_1", "vector_2");

await _client.DeleteVectorNameAsync(new()
{
CollectionName = collectionName,
VectorName = "vector_2",
Wait = true
});

info = await _client.GetCollectionInfoAsync(collectionName);
vectors = info.Config.Params.VectorsConfig.ParamsMap.Map;
vectors.Should().HaveCount(1).And.ContainKeys("vector_1");
}


public async Task InitializeAsync()
{
foreach (var collection in await _client.ListCollectionsAsync())
Expand Down
Loading