mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 03:47:02 +02:00
missing payload error
This commit is contained in:
parent
18cb514073
commit
4eb3817b03
6 changed files with 49 additions and 17 deletions
|
@ -133,13 +133,16 @@ pub async fn add_documents(
|
|||
) -> Result<HttpResponse, ResponseError> {
|
||||
debug!("called with params: {:?}", params);
|
||||
document_addition(
|
||||
req.headers().get("Content-type").map(|s| s.to_str().unwrap_or("unkown")),
|
||||
req.headers()
|
||||
.get("Content-type")
|
||||
.map(|s| s.to_str().unwrap_or("unkown")),
|
||||
meilisearch,
|
||||
path.into_inner().index_uid,
|
||||
params.into_inner().primary_key,
|
||||
body,
|
||||
IndexDocumentsMethod::ReplaceDocuments)
|
||||
.await
|
||||
IndexDocumentsMethod::ReplaceDocuments,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn update_documents(
|
||||
|
@ -151,13 +154,16 @@ pub async fn update_documents(
|
|||
) -> Result<HttpResponse, ResponseError> {
|
||||
debug!("called with params: {:?}", params);
|
||||
document_addition(
|
||||
req.headers().get("Content-type").map(|s| s.to_str().unwrap_or("unkown")),
|
||||
req.headers()
|
||||
.get("Content-type")
|
||||
.map(|s| s.to_str().unwrap_or("unkown")),
|
||||
meilisearch,
|
||||
path.into_inner().index_uid,
|
||||
params.into_inner().primary_key,
|
||||
body,
|
||||
IndexDocumentsMethod::UpdateDocuments)
|
||||
.await
|
||||
IndexDocumentsMethod::UpdateDocuments,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Route used when the payload type is "application/json"
|
||||
|
@ -174,7 +180,9 @@ async fn document_addition(
|
|||
Some("application/json") => DocumentAdditionFormat::Json,
|
||||
Some("application/x-ndjson") => DocumentAdditionFormat::Ndjson,
|
||||
Some("text/csv") => DocumentAdditionFormat::Csv,
|
||||
Some(other) => return Err(MeilisearchHttpError::InvalidContentType(other.to_string()).into()),
|
||||
Some(other) => {
|
||||
return Err(MeilisearchHttpError::InvalidContentType(other.to_string()).into())
|
||||
}
|
||||
None => return Err(MeilisearchHttpError::MissingContentType.into()),
|
||||
};
|
||||
|
||||
|
@ -185,9 +193,7 @@ async fn document_addition(
|
|||
format,
|
||||
};
|
||||
|
||||
let update_status = meilisearch
|
||||
.register_update(index_uid, update, true)
|
||||
.await?;
|
||||
let update_status = meilisearch.register_update(index_uid, update, true).await?;
|
||||
|
||||
debug!("returns: {:?}", update_status);
|
||||
Ok(HttpResponse::Accepted().json(serde_json::json!({ "updateId": update_status.id() })))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue