This project demonstrates the integration and basic usage of the qdrant_client
with Rust to interact with a Qdrant vector database. Qdrant is a vector search engine that allows for efficient storage and retrieval of high-dimensional vectors, making it suitable for tasks like similarity search, machine learning model outputs, or any scenario requiring nearest neighbor searches.
The provided Rust example covers a comprehensive workflow with the Qdrant vector database, including:
- Establishing a connection with the Qdrant database.
- Listing existing collections in the database.
- Creating and deleting a collection.
- Inserting vector data with associated JSON payloads.
- Performing a vector similarity search with payload filtering.
This example showcases how to utilize asynchronous Rust programming with the tokio
runtime to interact with Qdrant, handling vector data, and performing complex searches.
To run this example, ensure you have the following:
- Rust programming environment.
tokio
runtime for asynchronous operations.qdrant_client
to interact with Qdrant.serde_json
for JSON serialization and deserialization.- A running Qdrant server (locally or hosted).
-
Setting up Qdrant: Make sure you have a Qdrant server running and accessible. By default, this example assumes the server is available at
http://localhost:6334
. -
Dependencies: Add the necessary dependencies to your
Cargo.toml
:[dependencies] anyhow = "1.0" tokio = { version = "1", features = ["full"] } qdrant_client = "0.1" serde_json = "1.0"
-
Running the Example: The provided Rust script can be executed as a standalone application. It performs the following operations in sequence:
- Connection: Establishes a connection with the Qdrant server.
- List Collections: Retrieves and displays a list of existing collections in the database.
- Create/Delete Collection: Demonstrates how to create a new collection named
test
, and if it already exists, deletes it before recreation. - Insert Data: Inserts a point into the
test
collection with a 10-dimensional vector and an associated JSON payload. - Search: Performs a search for vectors similar to the given query vector, filtering results based on payload values, and retrieves the associated payload.
- Display Result: Extracts and prints a specific part of the payload (
baz
) from the search results.
-
Output: The example's execution will log various stages of interaction with Qdrant, including creating collections, inserting data, and the results of the vector search.
This Rust example offers a basic framework for integrating and leveraging the Qdrant vector database for vector similarity searches and managing vector data collections. It demonstrates essential operations like collection management, data insertion, and executing filtered search queries, providing a foundation for building more complex vector database interactions in Rust applications.