Skip to content

Collections

Manage Qdrant collections -- create, list, inspect, and delete.

This example assumes using Qdrant; is in scope and apiKey contains your Qdrant API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var client = Client;
var collectionName = $"test_collection_{Guid.NewGuid():N}";

// Create a new collection with 4-dimensional vectors using Cosine distance.

var createResponse = await client.Collections.CreateCollectionAsync(
    collectionName: collectionName,
    vectors: new VectorParams
    {
        Size = 4,
        Distance = Distance.Cosine,
    });

Console.WriteLine($"Collection '{collectionName}' created successfully.");

// List all collections and verify the new one exists.

var listResponse = await client.Collections.GetCollectionsAsync();

listResponse.Result!.Collections

Console.WriteLine($"Found {listResponse.Result.Collections.Count} collection(s).");

// Check that the collection exists using the dedicated endpoint.

var existsResponse = await client.Collections.CollectionExistsAsync(
    collectionName: collectionName);

// Get detailed information about the collection.

var getResponse = await client.Collections.GetCollectionAsync(
    collectionName: collectionName);

Console.WriteLine($"Collection status: {getResponse.Result!.Status}");
Console.WriteLine($"Points count: {getResponse.Result.PointsCount}");

// Delete the collection.

var deleteResponse = await client.Collections.DeleteCollectionAsync(
    collectionName: collectionName);

Console.WriteLine($"Collection '{collectionName}' deleted.");

// Verify the collection no longer exists.

var existsAfterDelete = await client.Collections.CollectionExistsAsync(
    collectionName: collectionName);