Qdrant
Qdrant is an open source vector database designed for scalable and efficient similarity search and nearest neighbor retrieval. It provides both RESTful and gRPC APIs, making it easy to integrate with various applications, including search, recommendation, AI, and machine learning systems.
Add the following dependency to your project file:
NuGet | |
---|---|
1 |
|
You can start an Qdrant container instance from any .NET application. This example uses xUnit.net's IAsyncLifetime
interface to manage the lifecycle of the container. The container is started in the InitializeAsync
method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the DisposeAsync
method.
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 |
|
The test example uses the following NuGet dependencies:
1 2 3 4 5 |
|
To execute the tests, use the command dotnet test
from a terminal.
Tip
For the complete source code of this example and additional information, please refer to our test projects.
Configure API key
To set and configure an API key, use the following container builder method:
1 |
|
Make sure the underlying Qdrant HTTP or gRPC client adds the API key to the HTTP header or gRPC metadata:
1 |
|
Configure TLS
The following example generates a self-signed certificate and configures the module to use TLS with the certificate and private key:
Note
Please ensure that both the certificate and private key are provided in PEM format.
1 |
|
The Qdrant client is configured to validate the TLS certificate using its thumbprint:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
A Note To Developers
The module creates a container that listens to requests over HTTP. The official Qdrant client uses the gRPC APIs to communicate with Qdrant. .NET Core and .NET support the above example with no additional configuration. However, .NET Framework has limited supported for gRPC over HTTP/2, but it can be enabled by:
- Configuring the module to use TLS.
- Configuring server certificate validation.
- Reference
System.Net.Http.WinHttpHandler
version6.0.1
or later, and configureWinHttpHandler
as the handler forGrpcChannelOptions
in the Qdrant client.
Refer to the official Qdrant .NET SDK for more information.