implement delete document batches

This commit is contained in:
mpostma 2021-02-12 17:39:14 +01:00
parent a8ba809656
commit c317af58bc
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
5 changed files with 68 additions and 7 deletions

View file

@ -160,11 +160,25 @@ async fn update_documents(
wrap = "Authentication::Private"
)]
async fn delete_documents(
_data: web::Data<Data>,
_path: web::Path<IndexParam>,
_body: web::Json<Vec<Value>>,
data: web::Data<Data>,
path: web::Path<IndexParam>,
body: web::Json<Vec<Value>>,
) -> Result<HttpResponse, ResponseError> {
todo!()
let ids = body
.iter()
.map(ToString::to_string)
.collect();
match data.delete_documents(&path.index_uid, ids).await {
Ok(result) => {
let json = serde_json::to_string(&result).unwrap();
Ok(HttpResponse::Ok().body(json))
}
Err(e) => {
error!("{}", e);
unimplemented!()
}
}
}
#[delete("/indexes/{index_uid}/documents", wrap = "Authentication::Private")]