A MoonBit client for the Qdrant vector database REST API.
Dependencies
moon add yuzhiblue/moon-qdrantdocker run -p 6333:6333 qdrant/qdrantlet client = QdrantClient::new("http://localhost:6333")
// health check
let ok = client.health()
// create a collection with 4-dimensional cosine vectors
client.create_collection(
"demo",
CollectionConfig::new(VectorParams::new(4, Distance::Cosine)),
)
// list collections
let names = client.list_collections()
// inspect a collection
let info = client.collection_info("demo")
// does it exist?
let exists = client.collection_exists("demo")
// write some points
client.upsert_points("demo", [
PointStruct::new(1, [0.1, 0.2, 0.3, 0.4], { "tag": "alpha" }),
PointStruct::new(2, [0.5, 0.6, 0.7, 0.8], { "tag": "beta" }),
])
// read one back
let point = client.get_point("demo", 1)
// search for the most similar points
let hits = client.search_points("demo", [0.1, 0.2, 0.3, 0.4], limit=2)
// search with a payload filter
let filtered = client.search_points(
"demo",
[0.1, 0.2, 0.3, 0.4],
limit=2,
filter={ "must": [{ "key": "tag", "match": { "value": "alpha" } }] },
)
// delete points by id
client.delete_points("demo", [2])
// drop the collection
client.delete_collection("demo")moon run cmd/main -- http://localhost:6333docker run -p 6333:6333 qdrant/qdrant
moon run examples/demo -- http://localhost:6333moon check --deny-warn
moon test
moon fmtpub trait VectorProvider {
async fn create_collection(self : Self, name : String, config : CollectionConfig) -> Unit
async fn delete_collection(self : Self, name : String) -> Unit
async fn collection_exists(self : Self, name : String) -> Bool
async fn upsert_points(self : Self, name : String, points : Array[PointStruct]) -> Unit
async fn upsert_points_batch(self : Self, name : String, points : Array[PointStruct]) -> Unit
async fn search_points(self : Self, name : String, vector : Array[Double], limit : Int, filter? : Json?) -> Array[ScoredPoint]
}pub struct CollectionSummary {
name : String
}pub(all) enum Distance {
Cosine
Euclid
Dot
}impl VectorProvider for QdrantClientasync fn search_points(self : QdrantClient, name : String, vector : Array[Double], limit : Int, filter? : Json?) -> Array[ScoredPoint]async fn upsert_points_batch(self : QdrantClient, name : String, points : Array[PointStruct]) -> Unitasync fn QdrantClient::create_collection(self : QdrantClient, name : String, config : CollectionConfig) -> Unitasync fn QdrantClient::search_points(self : QdrantClient, name : String, vector : Array[Double], limit : Int, filter? : Json?) -> Array[ScoredPoint]async fn QdrantClient::upsert_points(self : QdrantClient, name : String, points : Array[PointStruct]) -> Unitasync fn QdrantClient::upsert_points_batch(self : QdrantClient, name : String, points : Array[PointStruct]) -> UnitInstall
Download zipA MoonBit client for the Qdrant vector database REST API.
Dependencies