mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
fix test after rebase
This commit is contained in:
parent
36c7fd0cf1
commit
99866ba484
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1536,7 +1536,6 @@ dependencies = [
|
|||||||
"meilisearch-schema",
|
"meilisearch-schema",
|
||||||
"meilisearch-tokenizer",
|
"meilisearch-tokenizer",
|
||||||
"mime",
|
"mime",
|
||||||
"once_cell",
|
|
||||||
"pretty-bytes",
|
"pretty-bytes",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -53,7 +53,6 @@ whoami = "0.8.1"
|
|||||||
http-service = "0.4.0"
|
http-service = "0.4.0"
|
||||||
http-service-mock = "0.4.0"
|
http-service-mock = "0.4.0"
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
once_cell = "1.3.1"
|
|
||||||
tokio = { version = "0.2.18", features = ["macros", "time"] }
|
tokio = { version = "0.2.18", features = ["macros", "time"] }
|
||||||
|
|
||||||
[dev-dependencies.assert-json-diff]
|
[dev-dependencies.assert-json-diff]
|
||||||
|
@ -172,15 +172,9 @@ impl<'a> SearchBuilder<'a> {
|
|||||||
|
|
||||||
let mut hits = Vec::with_capacity(self.limit);
|
let mut hits = Vec::with_capacity(self.limit);
|
||||||
for doc in docs {
|
for doc in docs {
|
||||||
// retrieve the content of document in kv store
|
|
||||||
let attributes: Option<HashSet<&str>> = self
|
|
||||||
.attributes_to_retrieve
|
|
||||||
.as_ref()
|
|
||||||
.map(|a| a.iter().map(|a| a.as_str()).collect());
|
|
||||||
|
|
||||||
let mut document: IndexMap<String, Value> = self
|
let mut document: IndexMap<String, Value> = self
|
||||||
.index
|
.index
|
||||||
.document(reader, attributes.as_ref(), doc.id)
|
.document(reader, Some(&all_attributes), doc.id)
|
||||||
.map_err(|e| ResponseError::retrieve_document(doc.id.0, e))?
|
.map_err(|e| ResponseError::retrieve_document(doc.id.0, e))?
|
||||||
.ok_or(ResponseError::internal(
|
.ok_or(ResponseError::internal(
|
||||||
"Impossible to retrieve the document; Corrupted data",
|
"Impossible to retrieve the document; Corrupted data",
|
||||||
|
@ -41,11 +41,12 @@ async fn get_document(
|
|||||||
.db
|
.db
|
||||||
.open_index(&path.index_uid)
|
.open_index(&path.index_uid)
|
||||||
.ok_or(ResponseError::index_not_found(&path.index_uid))?;
|
.ok_or(ResponseError::index_not_found(&path.index_uid))?;
|
||||||
|
|
||||||
let document_id = meilisearch_core::serde::compute_document_id(&path.document_id);
|
let document_id = meilisearch_core::serde::compute_document_id(&path.document_id);
|
||||||
|
|
||||||
let reader = data.db.main_read_txn()?;
|
let reader = data.db.main_read_txn()?;
|
||||||
|
|
||||||
let response = index
|
let response: Document = index
|
||||||
.document(&reader, None, document_id)?
|
.document(&reader, None, document_id)?
|
||||||
.ok_or(ResponseError::document_not_found(&path.document_id))?;
|
.ok_or(ResponseError::document_not_found(&path.document_id))?;
|
||||||
|
|
||||||
|
@ -1,23 +1,18 @@
|
|||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
use std::sync::Mutex;
|
|
||||||
|
|
||||||
use assert_json_diff::assert_json_eq;
|
use assert_json_diff::assert_json_eq;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
static GLOBAL_SERVER: Lazy<Mutex<common::Server>> = Lazy::new(|| {
|
|
||||||
let mut server = common::Server::with_uid("movies");
|
|
||||||
server.populate_movies();
|
|
||||||
Mutex::new(server)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
// q: Captain
|
// q: Captain
|
||||||
// limit: 3
|
// limit: 3
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_limit() {
|
async fn search_with_limit() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=3";
|
let query = "q=captain&limit=3";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -74,7 +69,7 @@ async fn search_with_limit() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +79,9 @@ async fn search_with_limit() {
|
|||||||
// offset: 1
|
// offset: 1
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_offset() {
|
async fn search_with_offset() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=3&offset=1";
|
let query = "q=captain&limit=3&offset=1";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -141,7 +139,7 @@ async fn search_with_offset() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +149,9 @@ async fn search_with_offset() {
|
|||||||
// attributeToHighlight: *
|
// attributeToHighlight: *
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attribute_to_highlight_wildcard() {
|
async fn search_with_attribute_to_highlight_wildcard() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToHighlight=*";
|
let query = "q=captain&limit=1&attributesToHighlight=*";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -190,7 +191,7 @@ async fn search_with_attribute_to_highlight_wildcard() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +201,9 @@ async fn search_with_attribute_to_highlight_wildcard() {
|
|||||||
// attributeToHighlight: title
|
// attributeToHighlight: title
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attribute_to_highlight_1() {
|
async fn search_with_attribute_to_highlight_1() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToHighlight=title";
|
let query = "q=captain&limit=1&attributesToHighlight=title";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -239,7 +243,7 @@ async fn search_with_attribute_to_highlight_1() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +253,9 @@ async fn search_with_attribute_to_highlight_1() {
|
|||||||
// attributeToHighlight: title,tagline
|
// attributeToHighlight: title,tagline
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attribute_to_highlight_title_tagline() {
|
async fn search_with_attribute_to_highlight_title_tagline() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToHighlight=title,tagline";
|
let query = "q=captain&limit=1&attributesToHighlight=title,tagline";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -288,7 +295,7 @@ async fn search_with_attribute_to_highlight_title_tagline() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,6 +305,9 @@ async fn search_with_attribute_to_highlight_title_tagline() {
|
|||||||
// attributeToHighlight: title,overview
|
// attributeToHighlight: title,overview
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attribute_to_highlight_title_overview() {
|
async fn search_with_attribute_to_highlight_title_overview() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToHighlight=title,overview";
|
let query = "q=captain&limit=1&attributesToHighlight=title,overview";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -337,7 +347,7 @@ async fn search_with_attribute_to_highlight_title_overview() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,6 +357,9 @@ async fn search_with_attribute_to_highlight_title_overview() {
|
|||||||
// matches: true
|
// matches: true
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_matches() {
|
async fn search_with_matches() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&matches=true";
|
let query = "q=captain&limit=1&matches=true";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -383,7 +396,7 @@ async fn search_with_matches() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,6 +407,9 @@ async fn search_with_matches() {
|
|||||||
// cropLength: 20
|
// cropLength: 20
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_witch_crop() {
|
async fn search_witch_crop() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToCrop=overview&cropLength=20";
|
let query = "q=captain&limit=1&attributesToCrop=overview&cropLength=20";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -433,7 +449,7 @@ async fn search_witch_crop() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +459,9 @@ async fn search_witch_crop() {
|
|||||||
// attributesToRetrieve: [title,tagline,overview,poster_path]
|
// attributesToRetrieve: [title,tagline,overview,poster_path]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attributes_to_retrieve() {
|
async fn search_with_attributes_to_retrieve() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,tagline,overview,poster_path";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,tagline,overview,poster_path";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -454,7 +473,7 @@ async fn search_with_attributes_to_retrieve() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +483,9 @@ async fn search_with_attributes_to_retrieve() {
|
|||||||
// attributesToRetrieve: *
|
// attributesToRetrieve: *
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attributes_to_retrieve_wildcard() {
|
async fn search_with_attributes_to_retrieve_wildcard() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=*";
|
let query = "q=captain&limit=1&attributesToRetrieve=*";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -486,7 +508,7 @@ async fn search_with_attributes_to_retrieve_wildcard() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,6 +518,9 @@ async fn search_with_attributes_to_retrieve_wildcard() {
|
|||||||
// filters: director:Anthony%20Russo
|
// filters: director:Anthony%20Russo
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_filter() {
|
async fn search_with_filter() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&filters=director%20%3D%20%22Anthony%20Russo%22&limit=3";
|
let query = "q=captain&filters=director%20%3D%20%22Anthony%20Russo%22&limit=3";
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
{
|
{
|
||||||
@ -550,7 +575,7 @@ async fn search_with_filter() {
|
|||||||
"vote_count": 10497
|
"vote_count": 10497
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -574,7 +599,7 @@ async fn search_with_filter() {
|
|||||||
|
|
||||||
// filters: title = "american pie 2"
|
// filters: title = "american pie 2"
|
||||||
let query = "q=american&filters=title%20%3D%20%22american%20pie%202%22";
|
let query = "q=american&filters=title%20%3D%20%22american%20pie%202%22";
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -615,7 +640,7 @@ async fn search_with_filter() {
|
|||||||
]);
|
]);
|
||||||
// limit: 3, director = "anthony russo" AND (title = "captain america: civil war" OR title = "Captain America: The Winter Soldier")
|
// limit: 3, director = "anthony russo" AND (title = "captain america: civil war" OR title = "Captain America: The Winter Soldier")
|
||||||
let query = "q=a&limit=3&filters=director%20%3D%20%22anthony%20russo%22%20AND%20%20(title%20%3D%20%22captain%20america%3A%20civil%20war%22%20OR%20title%20%3D%20%22Captain%20America%3A%20The%20Winter%20Soldier%22)";
|
let query = "q=a&limit=3&filters=director%20%3D%20%22anthony%20russo%22%20AND%20%20(title%20%3D%20%22captain%20america%3A%20civil%20war%22%20OR%20title%20%3D%20%22Captain%20America%3A%20The%20Winter%20Soldier%22)";
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -673,7 +698,7 @@ async fn search_with_filter() {
|
|||||||
]);
|
]);
|
||||||
// director = "anthony russo" AND (title = "captain america: civil war" OR vote_average > 8.0)
|
// director = "anthony russo" AND (title = "captain america: civil war" OR vote_average > 8.0)
|
||||||
let query = "q=a&limit=3&filters=director%20%3D%20%22anthony%20russo%22%20AND%20%20(title%20%3D%20%22captain%20america%3A%20civil%20war%22%20OR%20vote_average%20%3E%208.0)";
|
let query = "q=a&limit=3&filters=director%20%3D%20%22anthony%20russo%22%20AND%20%20(title%20%3D%20%22captain%20america%3A%20civil%20war%22%20OR%20vote_average%20%3E%208.0)";
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -730,12 +755,12 @@ async fn search_with_filter() {
|
|||||||
]);
|
]);
|
||||||
// NOT director = "anthony russo" AND vote_average > 7.5
|
// NOT director = "anthony russo" AND vote_average > 7.5
|
||||||
let query = "q=a&limit=3&filters=NOT%20director%20%3D%20%22anthony%20russo%22%20AND%20vote_average%20%3E%207.5";
|
let query = "q=a&limit=3&filters=NOT%20director%20%3D%20%22anthony%20russo%22%20AND%20vote_average%20%3E%207.5";
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
|
|
||||||
let expected = json!([]);
|
let expected = json!([]);
|
||||||
let query = "q=a&filters=NOT%20director%20%3D%20%22anthony%20russo%22%20AND%20title%20%20%3D%20%22Avengers%3A%20Endgame%22";
|
let query = "q=a&filters=NOT%20director%20%3D%20%22anthony%20russo%22%20AND%20title%20%20%3D%20%22Avengers%3A%20Endgame%22";
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query);
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,6 +771,9 @@ async fn search_with_filter() {
|
|||||||
// matches: true
|
// matches: true
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attributes_to_highlight_and_matches() {
|
async fn search_with_attributes_to_highlight_and_matches() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToHighlight=title,overview&matches=true";
|
let query = "q=captain&limit=1&attributesToHighlight=title,overview&matches=true";
|
||||||
|
|
||||||
let expected = json!( [
|
let expected = json!( [
|
||||||
@ -799,7 +827,7 @@ async fn search_with_attributes_to_highlight_and_matches() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,6 +840,9 @@ async fn search_with_attributes_to_highlight_and_matches() {
|
|||||||
// attributesToCrop: overview
|
// attributesToCrop: overview
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToCrop=overview&cropLength=20&attributesToHighlight=title,overview&matches=true";
|
let query = "q=captain&limit=1&attributesToCrop=overview&cropLength=20&attributesToHighlight=title,overview&matches=true";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -865,7 +896,7 @@ async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,6 +907,9 @@ async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
|||||||
// attributesToHighlight: [title]
|
// attributesToHighlight: [title]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes() {
|
async fn search_with_differents_attributes() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToHighlight=title";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToHighlight=title";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -889,7 +923,7 @@ async fn search_with_differents_attributes() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,6 +935,9 @@ async fn search_with_differents_attributes() {
|
|||||||
// cropLength: 10
|
// cropLength: 10
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_2() {
|
async fn search_with_differents_attributes_2() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview&cropLength=10";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview&cropLength=10";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -914,7 +951,7 @@ async fn search_with_differents_attributes_2() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -925,6 +962,9 @@ async fn search_with_differents_attributes_2() {
|
|||||||
// attributesToCrop: [overview:10]
|
// attributesToCrop: [overview:10]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_3() {
|
async fn search_with_differents_attributes_3() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview:10";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview:10";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -938,7 +978,7 @@ async fn search_with_differents_attributes_3() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,6 +989,9 @@ async fn search_with_differents_attributes_3() {
|
|||||||
// attributesToCrop: [overview:10,title:0]
|
// attributesToCrop: [overview:10,title:0]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_4() {
|
async fn search_with_differents_attributes_4() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview:10,title:0";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=overview:10,title:0";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -963,7 +1006,7 @@ async fn search_with_differents_attributes_4() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,6 +1017,9 @@ async fn search_with_differents_attributes_4() {
|
|||||||
// attributesToCrop: [*,overview:10]
|
// attributesToCrop: [*,overview:10]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_5() {
|
async fn search_with_differents_attributes_5() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -990,7 +1036,7 @@ async fn search_with_differents_attributes_5() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,6 +1048,9 @@ async fn search_with_differents_attributes_5() {
|
|||||||
// attributesToHighlight: [title]
|
// attributesToHighlight: [title]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_6() {
|
async fn search_with_differents_attributes_6() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=title";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=title";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -1018,7 +1067,7 @@ async fn search_with_differents_attributes_6() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,6 +1079,9 @@ async fn search_with_differents_attributes_6() {
|
|||||||
// attributesToHighlight: [*]
|
// attributesToHighlight: [*]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_7() {
|
async fn search_with_differents_attributes_7() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=*";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=*";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -1046,7 +1098,7 @@ async fn search_with_differents_attributes_7() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1058,6 +1110,9 @@ async fn search_with_differents_attributes_7() {
|
|||||||
// attributesToHighlight: [*,tagline]
|
// attributesToHighlight: [*,tagline]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_differents_attributes_8() {
|
async fn search_with_differents_attributes_8() {
|
||||||
|
let mut server = common::Server::with_uid("movies");
|
||||||
|
server.populate_movies().await;
|
||||||
|
|
||||||
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=*,tagline";
|
let query = "q=captain&limit=1&attributesToRetrieve=title,producer,director&attributesToCrop=*,overview:10&attributesToHighlight=*,tagline";
|
||||||
|
|
||||||
let expected = json!([
|
let expected = json!([
|
||||||
@ -1075,6 +1130,6 @@ async fn search_with_differents_attributes_8() {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = GLOBAL_SERVER.lock().unwrap().search(query).await;
|
let (response, _status_code) = server.search(query).await;
|
||||||
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expected, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user