mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
receive update
This commit is contained in:
parent
672a4b5400
commit
6bcc302950
8 changed files with 181 additions and 459 deletions
|
@ -3,7 +3,7 @@ use actix_web::{delete, get, post, put};
|
|||
use actix_web::{web, HttpResponse};
|
||||
use indexmap::IndexMap;
|
||||
use log::error;
|
||||
//use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||
use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
|
@ -142,26 +142,25 @@ async fn add_documents_json(
|
|||
params: web::Query<UpdateDocumentsQuery>,
|
||||
body: Payload,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
todo!()
|
||||
//let addition_result = data
|
||||
//.add_documents(
|
||||
//path.into_inner().index_uid,
|
||||
//IndexDocumentsMethod::ReplaceDocuments,
|
||||
//UpdateFormat::Json,
|
||||
//body,
|
||||
//params.primary_key.clone(),
|
||||
//).await;
|
||||
let addition_result = data
|
||||
.add_documents(
|
||||
path.into_inner().index_uid,
|
||||
IndexDocumentsMethod::ReplaceDocuments,
|
||||
UpdateFormat::Json,
|
||||
body,
|
||||
params.primary_key.clone(),
|
||||
).await;
|
||||
|
||||
//match addition_result {
|
||||
//Ok(update) => {
|
||||
//let value = serde_json::to_string(&update).unwrap();
|
||||
//let response = HttpResponse::Ok().body(value);
|
||||
//Ok(response)
|
||||
//}
|
||||
//Err(e) => {
|
||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
//}
|
||||
//}
|
||||
match addition_result {
|
||||
Ok(update) => {
|
||||
let value = serde_json::to_string(&update).unwrap();
|
||||
let response = HttpResponse::Ok().body(value);
|
||||
Ok(response)
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue