mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
make retrieval non blocking
This commit is contained in:
parent
6766de437f
commit
8bb1b6146f
2 changed files with 75 additions and 62 deletions
|
@ -55,9 +55,9 @@ async fn get_document(
|
|||
data: web::Data<Data>,
|
||||
path: web::Path<DocumentParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let index = &path.index_uid;
|
||||
let id = &path.document_id;
|
||||
match data.retrieve_document(index, id, None) {
|
||||
let index = path.index_uid.clone();
|
||||
let id = path.document_id.clone();
|
||||
match data.retrieve_document(index, id, None as Option<Vec<String>>).await {
|
||||
Ok(document) => {
|
||||
let json = serde_json::to_string(&document).unwrap();
|
||||
Ok(HttpResponse::Ok().body(json))
|
||||
|
@ -99,13 +99,14 @@ async fn get_all_documents(
|
|||
.as_ref()
|
||||
.map(|attrs| attrs
|
||||
.split(",")
|
||||
.map(String::from)
|
||||
.collect::<Vec<_>>());
|
||||
|
||||
match data.retrieve_documents(
|
||||
&path.index_uid,
|
||||
path.index_uid.clone(),
|
||||
params.offset.unwrap_or(DEFAULT_RETRIEVE_DOCUMENTS_OFFSET),
|
||||
params.limit.unwrap_or(DEFAULT_RETRIEVE_DOCUMENTS_LIMIT),
|
||||
attributes_to_retrieve.as_deref()) {
|
||||
attributes_to_retrieve).await {
|
||||
Ok(docs) => {
|
||||
let json = serde_json::to_string(&docs).unwrap();
|
||||
Ok(HttpResponse::Ok().body(json))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue