Table of Contents

Getting started

Installing

The gRPC client is available on nuget, and can be installed with

dotnet add package Qdrant.Grpc

Creating the client

Create a new instance of the client with

var channel = QdrantChannel.ForAddress("http://localhost:6334");
var client = new QdrantGrpcClient(channel);

The client is thread safe, so create a single instance and reuse it.

Creating a collection

Create a new collection with

var collectionOperationResponse = await client.Collections.CreateAsync(new CreateCollection
{
    CollectionName = "my_collection",
    VectorsConfig = new VectorsConfig
    {
        Params = new VectorParams
        {
            Size = 1536,
            Distance = Distance.Cosine
        }
    }
});

Indexing

Points are the central entity that Qdrant operates with. A point has a vector and an optional payload. Points can be indexed with

var pointsOperationResponse = await client.Points.UpsertAsync(new UpsertPoints
{
    CollectionName = "my_collection",
    Ordering = WriteOrderingType.Medium,
    Wait = true,
    Points =
    {
        new PointStruct
        {
            Id = 1,
            Vectors = new Vectors { Vector = new []{ 1, 2, 3, 4 } },
            Payload =
            {
                ["color"] = "blue",
                ["count"] = 7,
                ["precision"] = 0.866
            }
        },
        new PointStruct
        {
            Id = 2,
            Vectors = new Vectors { Vector = new[] { 2, 3, 4, 5 } },
            Payload =
            {
                ["color"] = "red",
                ["count"] = 5,
                ["precision"] = 0.9992
            }
        }
    }
});

The write ordering defines the ordering guarantees of the operation.

To perform an Approximate Nearest Neighbour (ANN) search

var searchResponse = await client.Points.SearchAsync(new SearchPoints
{
    Vector = { 1, 3, 4, 5 },
    Params = new SearchParams
    {
        HnswEf = 10,
        Exact = false
    },
    Limit = 10
});

This will return the nearest neighbours up to the limit specified.

Deleting a collection

Delete an existing collection with

var collectionOperationResponse = await client.Collections.DeleteAsync(new DeleteCollection
{
    CollectionName = "my_collection",
    Timeout = 10
});

The timeout specifies how long to wait for the operation to commit.