mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 21:50:07 +01:00
implement clear documents
This commit is contained in:
parent
ae5581d37c
commit
a955e04ab6
@ -34,12 +34,10 @@ impl Data {
|
|||||||
|
|
||||||
pub async fn clear_documents(
|
pub async fn clear_documents(
|
||||||
&self,
|
&self,
|
||||||
_index: impl AsRef<str> + Sync + Send + 'static,
|
index: impl AsRef<str> + Sync + Send + 'static,
|
||||||
) -> anyhow::Result<UpdateStatus> {
|
) -> anyhow::Result<UpdateStatus> {
|
||||||
todo!()
|
let update = self.index_controller.clear_documents(index.as_ref().to_string()).await?;
|
||||||
//let index_controller = self.index_controller.clone();
|
Ok(update)
|
||||||
//let update = tokio::task::spawn_blocking(move || index_controller.clear_documents(index)).await??;
|
|
||||||
//Ok(update.into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_documents(
|
pub async fn delete_documents(
|
||||||
|
@ -106,8 +106,12 @@ impl IndexController {
|
|||||||
Ok(status)
|
Ok(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_documents(&self, index: String) -> anyhow::Result<UpdateStatus> {
|
pub async fn clear_documents(&self, index: String) -> anyhow::Result<UpdateStatus> {
|
||||||
todo!()
|
let uuid = self.uuid_resolver.resolve(index).await.unwrap().unwrap();
|
||||||
|
let meta = UpdateMeta::ClearDocuments;
|
||||||
|
let (_, receiver) = mpsc::channel(1);
|
||||||
|
let status = self.update_handle.update(meta, receiver, uuid).await?;
|
||||||
|
Ok(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_documents(&self, index: String, document_ids: Vec<String>) -> anyhow::Result<UpdateStatus> {
|
pub async fn delete_documents(&self, index: String, document_ids: Vec<String>) -> anyhow::Result<UpdateStatus> {
|
||||||
|
@ -250,14 +250,13 @@ async fn clear_all_documents(
|
|||||||
data: web::Data<Data>,
|
data: web::Data<Data>,
|
||||||
path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
todo!()
|
match data.clear_documents(path.index_uid.clone()).await {
|
||||||
//match data.clear_documents(path.index_uid.clone()).await {
|
Ok(update) => {
|
||||||
//Ok(update) => {
|
let json = serde_json::to_string(&update).unwrap();
|
||||||
//let json = serde_json::to_string(&update).unwrap();
|
Ok(HttpResponse::Ok().body(json))
|
||||||
//Ok(HttpResponse::Ok().body(json))
|
}
|
||||||
//}
|
Err(e) => {
|
||||||
//Err(e) => {
|
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
}
|
||||||
//}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user