mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-27 07:14:26 +01:00
cargo fmt
This commit is contained in:
parent
2644f087d0
commit
0a67248bfe
@ -3,14 +3,14 @@ use std::collections::{BTreeSet, HashSet};
|
||||
use actix_web::{delete, get, post, put};
|
||||
use actix_web::{web, HttpResponse};
|
||||
use indexmap::IndexMap;
|
||||
use meilisearch_core::{update, MainReader};
|
||||
use meilisearch_core::{update, Index};
|
||||
use serde_json::Value;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::Data;
|
||||
use crate::error::{Error, ResponseError};
|
||||
use crate::helpers::Authentication;
|
||||
use crate::routes::{IndexParam, IndexUpdateResponse};
|
||||
use crate::Data;
|
||||
|
||||
type Document = IndexMap<String, Value>;
|
||||
|
||||
@ -45,7 +45,8 @@ async fn get_document(
|
||||
|
||||
let reader = data.db.main_read_txn()?;
|
||||
|
||||
let internal_id = index.main
|
||||
let internal_id = index
|
||||
.main
|
||||
.external_to_internal_docid(&reader, &path.document_id)?
|
||||
.ok_or(Error::document_not_found(&path.document_id))?;
|
||||
|
||||
@ -189,6 +190,7 @@ fn create_index(data: &Data, uid: &str) -> Result<Index, ResponseError> {
|
||||
|
||||
Ok(created_index)
|
||||
}
|
||||
|
||||
async fn update_multiple_documents(
|
||||
data: web::Data<Data>,
|
||||
path: web::Path<IndexParam>,
|
||||
@ -215,12 +217,10 @@ async fn update_multiple_documents(
|
||||
None => body
|
||||
.first()
|
||||
.and_then(find_primary_key)
|
||||
.ok_or(meilisearch_core::Error::MissingPrimaryKey)?
|
||||
.ok_or(meilisearch_core::Error::MissingPrimaryKey)?,
|
||||
};
|
||||
|
||||
schema
|
||||
.set_primary_key(&id)
|
||||
.map_err(Error::bad_request)?;
|
||||
schema.set_primary_key(&id).map_err(Error::bad_request)?;
|
||||
|
||||
data.db.main_write(|w| index.main.put_schema(w, &schema))?;
|
||||
}
|
||||
@ -274,7 +274,6 @@ async fn delete_documents(
|
||||
.open_index(&path.index_uid)
|
||||
.ok_or(Error::index_not_found(&path.index_uid))?;
|
||||
|
||||
|
||||
let mut documents_deletion = index.documents_deletion();
|
||||
|
||||
for document_id in body.into_inner() {
|
||||
|
@ -192,7 +192,9 @@ async fn add_document_with_long_field() {
|
||||
"url":"/configuration/app/web.html#locations"
|
||||
}]);
|
||||
server.add_or_replace_multiple_documents(body).await;
|
||||
let (response, _status) = server.search_post(json!({ "q": "request_buffering" })).await;
|
||||
let (response, _status) = server
|
||||
.search_post(json!({ "q": "request_buffering" }))
|
||||
.await;
|
||||
assert!(!response["hits"].as_array().unwrap().is_empty());
|
||||
}
|
||||
|
||||
@ -213,6 +215,11 @@ async fn documents_with_same_id_are_overwritten() {
|
||||
server.add_or_replace_multiple_documents(documents).await;
|
||||
let (response, _status) = server.get_all_documents().await;
|
||||
assert_eq!(response.as_array().unwrap().len(), 1);
|
||||
assert_eq!(
|
||||
response.as_array().unwrap()[0].as_object().unwrap()["content"],
|
||||
"test2"
|
||||
);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn create_index_lazy_by_pushing_documents() {
|
||||
|
Loading…
Reference in New Issue
Block a user