use qail_qdrant::{Point, PointId, QdrantDriver};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Connecting to Qdrant...");
let mut driver = QdrantDriver::connect("localhost", 6334).await?;
println!("Connected!");
let _ = driver.delete_collection("upsert_debug_test").await;
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
println!("Creating test collection...");
driver
.create_collection(
"upsert_debug_test",
4, qail_qdrant::Distance::Cosine,
false,
)
.await?;
println!("Collection created");
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
let points = vec![
Point {
id: PointId::Num(1),
vector: vec![0.1, 0.2, 0.3, 0.4],
payload: std::collections::HashMap::new(),
},
Point {
id: PointId::Num(2),
vector: vec![0.5, 0.6, 0.7, 0.8],
payload: std::collections::HashMap::new(),
},
];
println!("Upserting {} points with wait=true...", points.len());
match driver.upsert("upsert_debug_test", &points, true).await {
Ok(_) => println!("Upsert returned Ok()"),
Err(e) => println!("Upsert error: {:?}", e),
}
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
println!("\nChecking via REST...");
let output = std::process::Command::new("curl")
.args(["-s", "http://localhost:6333/collections/upsert_debug_test"])
.output()?;
let info = String::from_utf8_lossy(&output.stdout);
println!("Collection info: {}", info);
if info.contains("\"points_count\":0") {
println!("\n❌ Points count is still 0!");
} else if info.contains("\"points_count\":") {
println!("\n✓ Points were inserted!");
}
println!("\nCleaning up...");
let _ = driver.delete_collection("upsert_debug_test").await;
Ok(())
}