Qdrant + FastEmbed with Rust
So none, I repeat none of this is “AI” generated! (Apart from the racing car 😉) . Let’s get that out of the way first and learn the code to link Qdrant with FastEmbed. Excuse the use of unwrap, this is didactic rather than “prod”.
I have put together the following useful notes on how to do embeddings for Qdrant using Rust with the FastEmbed crate for generating vector embeddings, reranking locally. This saves money on tokens, many tutorials use OpenAI for doing the embeddings!
Qdrant stores the embeddings for semantic retrieval, think “recommendation” or “similarity search”.

Qdrant + FastEmbed = FAST!!!
The code
Dependencies (Cargo.toml)
[dependencies]
dotenvy = "0.15.7"
fastembed = "5.8.1"
qdrant-client = "1.16.0"
serde_json = "1.0.149"
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
The “difficult” part is linking the examples from Qdrant for making a client and a collection to the FastEmbed examples on how to do embeddings.
Most of the code will seem relatively straightforward to work out, especially from the IDE hints, but this is the key part you won’t find:
// Prepare points with embeddings and corresponding documents as payload
let points: Vec<PointStruct> = embeddings
.into_iter()
.enumerate()
.filter(|(id, _)| !documents[*id].is_empty())
.map(|(id, vector)| {
let payload: Payload = serde_json::json!({ "document": documents[id] })
.try_into()
.unwrap();
PointStruct::new(id as u64, vector, payload)
})
.collect();
documents[ ] ─┐
├─ same index → (vector + payload) → PointStruct
embeddings[ ] ─┘
We’re strapping on the appropriate document to the id + embedding
Note the filter line?
Only keep the embeddings that have a real document attached, we skip the empty ones.
Also, note the * to deref the id?
Necessary because Rust doesn’t auto-deref tuple elements in closures.
Then, with map, we take a pair and turn it into a single “thing” that contains three bits of data, ready for the upsert to Qdrant!

Links:
https://qdrant.tech/documentation/fastembed/fastembed-semantic-search/
https://qdrant.tech/documentation/fastembed
https://crates.io/crates/fastembed
Massive thanks to Anush for making the FastEmbed crate!
