mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
3da607749f
@ -4,7 +4,7 @@ use actix_cors::Cors;
|
|||||||
use actix_web::{middleware, HttpServer};
|
use actix_web::{middleware, HttpServer};
|
||||||
use main_error::MainError;
|
use main_error::MainError;
|
||||||
use meilisearch_http::helpers::NormalizePath;
|
use meilisearch_http::helpers::NormalizePath;
|
||||||
use meilisearch_http::{Data, Opt, create_app, index_update_callback};
|
use meilisearch_http::{create_app, index_update_callback, Data, Opt};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
mod analytics;
|
mod analytics;
|
||||||
@ -19,7 +19,11 @@ async fn main() -> Result<(), MainError> {
|
|||||||
|
|
||||||
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||||
let _sentry = sentry::init((
|
let _sentry = sentry::init((
|
||||||
"https://5ddfa22b95f241198be2271aaf028653@sentry.io/3060337",
|
if !opt.no_sentry {
|
||||||
|
Some(opt.sentry_dsn.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
sentry::ClientOptions {
|
sentry::ClientOptions {
|
||||||
release: sentry::release_name!(),
|
release: sentry::release_name!(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@ -36,8 +40,8 @@ async fn main() -> Result<(), MainError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||||
if !opt.no_analytics {
|
if !opt.no_sentry && _sentry.is_enabled() {
|
||||||
sentry::integrations::panic::register_panic_handler();
|
sentry::integrations::panic::register_panic_handler(); // TODO: This shouldn't be needed when upgrading to sentry 0.19.0. These integrations are turned on by default when using `sentry::init`.
|
||||||
sentry::integrations::env_logger::init(None, Default::default());
|
sentry::integrations::env_logger::init(None, Default::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,9 +56,7 @@ async fn main() -> Result<(), MainError> {
|
|||||||
if !opt.no_analytics {
|
if !opt.no_analytics {
|
||||||
let analytics_data = data.clone();
|
let analytics_data = data.clone();
|
||||||
let analytics_opt = opt.clone();
|
let analytics_opt = opt.clone();
|
||||||
thread::spawn(move|| {
|
thread::spawn(move || analytics::analytics_sender(analytics_data, analytics_opt));
|
||||||
analytics::analytics_sender(analytics_data, analytics_opt)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let data_cloned = data.clone();
|
let data_cloned = data.clone();
|
||||||
@ -117,6 +119,16 @@ pub fn print_launch_resume(opt: &Opt, data: &Data) {
|
|||||||
env!("CARGO_PKG_VERSION").to_string()
|
env!("CARGO_PKG_VERSION").to_string()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||||
|
eprintln!(
|
||||||
|
"Sentry DSN:\t\t{:?}",
|
||||||
|
if !opt.no_sentry {
|
||||||
|
&opt.sentry_dsn
|
||||||
|
} else {
|
||||||
|
"Disabled"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
eprintln!();
|
eprintln!();
|
||||||
|
|
||||||
if data.api_keys.master.is_some() {
|
if data.api_keys.master.is_some() {
|
||||||
|
@ -10,7 +10,7 @@ pub fn services(cfg: &mut web::ServiceConfig) {
|
|||||||
cfg.service(get_health).service(change_healthyness);
|
cfg.service(get_health).service(change_healthyness);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/health", wrap = "Authentication::Private")]
|
#[get("/health")]
|
||||||
async fn get_health(data: web::Data<Data>) -> Result<HttpResponse, ResponseError> {
|
async fn get_health(data: web::Data<Data>) -> Result<HttpResponse, ResponseError> {
|
||||||
let reader = data.db.main_read_txn()?;
|
let reader = data.db.main_read_txn()?;
|
||||||
if let Ok(Some(_)) = data.db.get_health(&reader) {
|
if let Ok(Some(_)) = data.db.get_health(&reader) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -476,59 +476,4 @@ impl Server {
|
|||||||
pub async fn get_sys_info_pretty(&mut self) -> (Value, StatusCode) {
|
pub async fn get_sys_info_pretty(&mut self) -> (Value, StatusCode) {
|
||||||
self.get_request("/sys-info/pretty").await
|
self.get_request("/sys-info/pretty").await
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate routes
|
|
||||||
|
|
||||||
pub async fn populate_movies(&mut self) {
|
|
||||||
let body = json!({
|
|
||||||
"uid": "movies",
|
|
||||||
"primaryKey": "id",
|
|
||||||
});
|
|
||||||
self.create_index(body).await;
|
|
||||||
|
|
||||||
let body = json!({
|
|
||||||
"rankingRules": [
|
|
||||||
"typo",
|
|
||||||
"words",
|
|
||||||
"proximity",
|
|
||||||
"attribute",
|
|
||||||
"wordsPosition",
|
|
||||||
"desc(popularity)",
|
|
||||||
"exactness",
|
|
||||||
"desc(vote_average)",
|
|
||||||
],
|
|
||||||
"searchableAttributes": [
|
|
||||||
"title",
|
|
||||||
"tagline",
|
|
||||||
"overview",
|
|
||||||
"cast",
|
|
||||||
"director",
|
|
||||||
"producer",
|
|
||||||
"production_companies",
|
|
||||||
"genres",
|
|
||||||
],
|
|
||||||
"displayedAttributes": [
|
|
||||||
"title",
|
|
||||||
"director",
|
|
||||||
"producer",
|
|
||||||
"tagline",
|
|
||||||
"genres",
|
|
||||||
"id",
|
|
||||||
"overview",
|
|
||||||
"vote_count",
|
|
||||||
"vote_average",
|
|
||||||
"poster_path",
|
|
||||||
"popularity",
|
|
||||||
],
|
|
||||||
"acceptNewFields": false,
|
|
||||||
});
|
|
||||||
|
|
||||||
self.update_all_settings(body).await;
|
|
||||||
|
|
||||||
let dataset = include_bytes!("assets/movies.json");
|
|
||||||
|
|
||||||
let body: Value = serde_json::from_slice(dataset).unwrap();
|
|
||||||
|
|
||||||
self.add_or_replace_multiple_documents(body).await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,30 +2,33 @@ mod common;
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn delete() {
|
async fn delete() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let (_response, status_code) = server.get_document(419704).await;
|
let (_response, status_code) = server.get_document(50).await;
|
||||||
assert_eq!(status_code, 200);
|
assert_eq!(status_code, 200);
|
||||||
|
|
||||||
server.delete_document(419704).await;
|
server.delete_document(50).await;
|
||||||
|
|
||||||
let (_response, status_code) = server.get_document(419704).await;
|
let (_response, status_code) = server.get_document(50).await;
|
||||||
assert_eq!(status_code, 404);
|
assert_eq!(status_code, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the issue https://github.com/meilisearch/MeiliSearch/issues/493
|
// Resolve the issue https://github.com/meilisearch/MeiliSearch/issues/493
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn delete_batch() {
|
async fn delete_batch() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let (_response, status_code) = server.get_document(419704).await;
|
let doc_ids = vec!(50, 55, 60);
|
||||||
|
for doc_id in &doc_ids {
|
||||||
|
let (_response, status_code) = server.get_document(doc_id).await;
|
||||||
assert_eq!(status_code, 200);
|
assert_eq!(status_code, 200);
|
||||||
|
}
|
||||||
|
|
||||||
let body = serde_json::json!([419704, 512200, 181812]);
|
let body = serde_json::json!(&doc_ids);
|
||||||
server.delete_multiple_documents(body).await;
|
server.delete_multiple_documents(body).await;
|
||||||
|
|
||||||
let (_response, status_code) = server.get_document(419704).await;
|
for doc_id in &doc_ids {
|
||||||
|
let (_response, status_code) = server.get_document(doc_id).await;
|
||||||
assert_eq!(status_code, 404);
|
assert_eq!(status_code, 404);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -666,10 +666,10 @@ async fn check_add_documents_without_primary_key() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn check_first_update_should_bring_up_processed_status_after_first_docs_addition() {
|
async fn check_first_update_should_bring_up_processed_status_after_first_docs_addition() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
|
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 1. Create Index
|
// 1. Create Index
|
||||||
@ -677,7 +677,7 @@ async fn check_first_update_should_bring_up_processed_status_after_first_docs_ad
|
|||||||
assert_eq!(status_code, 201);
|
assert_eq!(status_code, 201);
|
||||||
assert_eq!(response["primaryKey"], json!(null));
|
assert_eq!(response["primaryKey"], json!(null));
|
||||||
|
|
||||||
let dataset = include_bytes!("assets/movies.json");
|
let dataset = include_bytes!("assets/test_set.json");
|
||||||
|
|
||||||
let body: Value = serde_json::from_slice(dataset).unwrap();
|
let body: Value = serde_json::from_slice(dataset).unwrap();
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,8 +6,7 @@ mod common;
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_basic() {
|
async fn search_with_settings_basic() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -16,33 +15,29 @@ async fn search_with_settings_basic() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"desc(popularity)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(vote_average)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"tagline",
|
"age",
|
||||||
"overview",
|
"color",
|
||||||
"cast",
|
"gender",
|
||||||
"director",
|
"email",
|
||||||
"producer",
|
"address",
|
||||||
"production_companies",
|
"about"
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"director",
|
"age",
|
||||||
"producer",
|
"gender",
|
||||||
"tagline",
|
"color",
|
||||||
"genres",
|
"email",
|
||||||
"id",
|
"phone",
|
||||||
"overview",
|
"address",
|
||||||
"vote_count",
|
"balance"
|
||||||
"vote_average",
|
|
||||||
"poster_path",
|
|
||||||
"popularity"
|
|
||||||
],
|
],
|
||||||
"stopWords": null,
|
"stopWords": null,
|
||||||
"synonyms": null,
|
"synonyms": null,
|
||||||
@ -51,58 +46,38 @@ async fn search_with_settings_basic() {
|
|||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=the%20avangers&limit=3";
|
let query = "q=ea%20exercitation&limit=3";
|
||||||
|
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 24428,
|
"balance": "$2,467.47",
|
||||||
"popularity": 44.506,
|
"age": 34,
|
||||||
"vote_average": 7.7,
|
"color": "blue",
|
||||||
"title": "The Avengers",
|
"name": "Patricia Goff",
|
||||||
"tagline": "Some assembly required.",
|
"gender": "female",
|
||||||
"overview": "When an unexpected enemy emerges and threatens global safety and security, Nick Fury, director of the international peacekeeping agency known as S.H.I.E.L.D., finds himself in need of a team to pull the world back from the brink of disaster. Spanning the globe, a daring recruitment effort begins!",
|
"email": "patriciagoff@chorizon.com",
|
||||||
"director": "Joss Whedon",
|
"phone": "+1 (864) 463-2277",
|
||||||
"producer": "Kevin Feige",
|
"address": "866 Hornell Loop, Cresaptown, Ohio, 1700"
|
||||||
"genres": [
|
|
||||||
"Science Fiction",
|
|
||||||
"Action",
|
|
||||||
"Adventure"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/cezWGskPY5x7GaglTTRN4Fugfb8.jpg",
|
|
||||||
"vote_count": 21079
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"balance": "$3,344.40",
|
||||||
"popularity": 38.659,
|
"age": 35,
|
||||||
"vote_average": 8.3,
|
"color": "blue",
|
||||||
"title": "Avengers: Endgame",
|
"name": "Adeline Flynn",
|
||||||
"tagline": "Part of the journey is the end.",
|
"gender": "female",
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
"email": "adelineflynn@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (994) 600-2840",
|
||||||
"producer": "Kevin Feige",
|
"address": "428 Paerdegat Avenue, Hollymead, Pennsylvania, 948"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction",
|
|
||||||
"Action"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg",
|
|
||||||
"vote_count": 10497
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"balance": "$3,394.96",
|
||||||
"popularity": 65.013,
|
"age": 25,
|
||||||
"vote_average": 8.3,
|
"color": "blue",
|
||||||
"title": "Avengers: Infinity War",
|
"name": "Aida Kirby",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"gender": "female",
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
"email": "aidakirby@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (942) 532-2325",
|
||||||
"producer": "Kevin Feige",
|
"address": "797 Engert Avenue, Wilsonia, Idaho, 6532"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Action",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
|
|
||||||
"vote_count": 16056
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -112,8 +87,7 @@ async fn search_with_settings_basic() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_stop_words() {
|
async fn search_with_settings_stop_words() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -122,93 +96,68 @@ async fn search_with_settings_stop_words() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"desc(popularity)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(vote_average)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"tagline",
|
"age",
|
||||||
"overview",
|
"color",
|
||||||
"cast",
|
"gender",
|
||||||
"director",
|
"email",
|
||||||
"producer",
|
"address",
|
||||||
"production_companies",
|
"about"
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"director",
|
"age",
|
||||||
"producer",
|
"gender",
|
||||||
"tagline",
|
"color",
|
||||||
"genres",
|
"email",
|
||||||
"id",
|
"phone",
|
||||||
"overview",
|
"address",
|
||||||
"vote_count",
|
"balance"
|
||||||
"vote_average",
|
|
||||||
"poster_path",
|
|
||||||
"popularity"
|
|
||||||
],
|
],
|
||||||
"stopWords": ["the"],
|
"stopWords": ["ea"],
|
||||||
"synonyms": null,
|
"synonyms": null,
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
});
|
});
|
||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=the%20avangers&limit=3";
|
let query = "q=ea%20exercitation&limit=3";
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"balance": "$1,921.58",
|
||||||
"popularity": 65.013,
|
"age": 31,
|
||||||
"vote_average": 8.3,
|
"color": "green",
|
||||||
"title": "Avengers: Infinity War",
|
"name": "Harper Carson",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"gender": "male",
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
"email": "harpercarson@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (912) 430-3243",
|
||||||
"producer": "Kevin Feige",
|
"address": "883 Dennett Place, Knowlton, New Mexico, 9219"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Action",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
|
|
||||||
"vote_count": 16056
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"balance": "$1,706.13",
|
||||||
"popularity": 38.659,
|
"age": 27,
|
||||||
"vote_average": 8.3,
|
"color": "green",
|
||||||
"title": "Avengers: Endgame",
|
"name": "Cherry Orr",
|
||||||
"tagline": "Part of the journey is the end.",
|
"gender": "female",
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
"email": "cherryorr@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (995) 479-3174",
|
||||||
"producer": "Kevin Feige",
|
"address": "442 Beverly Road, Ventress, New Mexico, 3361"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction",
|
|
||||||
"Action"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg",
|
|
||||||
"vote_count": 10497
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 99861,
|
"balance": "$1,476.39",
|
||||||
"popularity": 33.938,
|
"age": 28,
|
||||||
"vote_average": 7.3,
|
"color": "brown",
|
||||||
"title": "Avengers: Age of Ultron",
|
"name": "Maureen Dale",
|
||||||
"tagline": "A New Age Has Come.",
|
"gender": "female",
|
||||||
"overview": "When Tony Stark tries to jumpstart a dormant peacekeeping program, things go awry and Earth’s Mightiest Heroes are put to the ultimate test as the fate of the planet hangs in the balance. As the villainous Ultron emerges, it is up to The Avengers to stop him from enacting his terrible plans, and soon uneasy alliances and unexpected action pave the way for an epic and unique global adventure.",
|
"email": "maureendale@chorizon.com",
|
||||||
"director": "Joss Whedon",
|
"phone": "+1 (984) 538-3684",
|
||||||
"producer": "Kevin Feige",
|
"address": "817 Newton Street, Bannock, Wyoming, 1468"
|
||||||
"genres": [
|
|
||||||
"Action",
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg",
|
|
||||||
"vote_count": 14661
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -218,8 +167,7 @@ async fn search_with_settings_stop_words() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_synonyms() {
|
async fn search_with_settings_synonyms() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -228,39 +176,34 @@ async fn search_with_settings_synonyms() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"desc(popularity)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(vote_average)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"tagline",
|
"age",
|
||||||
"overview",
|
"color",
|
||||||
"cast",
|
"gender",
|
||||||
"director",
|
"email",
|
||||||
"producer",
|
"address",
|
||||||
"production_companies",
|
"about"
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"director",
|
"age",
|
||||||
"producer",
|
"gender",
|
||||||
"tagline",
|
"color",
|
||||||
"genres",
|
"email",
|
||||||
"id",
|
"phone",
|
||||||
"overview",
|
"address",
|
||||||
"vote_count",
|
"balance"
|
||||||
"vote_average",
|
|
||||||
"poster_path",
|
|
||||||
"popularity"
|
|
||||||
],
|
],
|
||||||
"stopWords": null,
|
"stopWords": null,
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"avangers": [
|
"application": [
|
||||||
"Captain America",
|
"exercitation"
|
||||||
"Iron Man"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
@ -268,58 +211,37 @@ async fn search_with_settings_synonyms() {
|
|||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=avangers&limit=3";
|
let query = "q=application&limit=3";
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"balance": "$1,921.58",
|
||||||
"popularity": 65.013,
|
"age": 31,
|
||||||
"vote_average": 8.3,
|
"color": "green",
|
||||||
"title": "Avengers: Infinity War",
|
"name": "Harper Carson",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"gender": "male",
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
"email": "harpercarson@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (912) 430-3243",
|
||||||
"producer": "Kevin Feige",
|
"address": "883 Dennett Place, Knowlton, New Mexico, 9219"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Action",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"vote_count": 16056,
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"balance": "$1,706.13",
|
||||||
"popularity": 38.659,
|
"age": 27,
|
||||||
"vote_average": 8.3,
|
"color": "green",
|
||||||
"title": "Avengers: Endgame",
|
"name": "Cherry Orr",
|
||||||
"tagline": "Part of the journey is the end.",
|
"gender": "female",
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
"email": "cherryorr@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (995) 479-3174",
|
||||||
"producer": "Kevin Feige",
|
"address": "442 Beverly Road, Ventress, New Mexico, 3361"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction",
|
|
||||||
"Action"
|
|
||||||
],
|
|
||||||
"vote_count": 10497,
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 99861,
|
"balance": "$1,476.39",
|
||||||
"popularity": 33.938,
|
"age": 28,
|
||||||
"vote_average": 7.3,
|
"color": "brown",
|
||||||
"title": "Avengers: Age of Ultron",
|
"name": "Maureen Dale",
|
||||||
"tagline": "A New Age Has Come.",
|
"gender": "female",
|
||||||
"overview": "When Tony Stark tries to jumpstart a dormant peacekeeping program, things go awry and Earth’s Mightiest Heroes are put to the ultimate test as the fate of the planet hangs in the balance. As the villainous Ultron emerges, it is up to The Avengers to stop him from enacting his terrible plans, and soon uneasy alliances and unexpected action pave the way for an epic and unique global adventure.",
|
"email": "maureendale@chorizon.com",
|
||||||
"director": "Joss Whedon",
|
"phone": "+1 (984) 538-3684",
|
||||||
"producer": "Kevin Feige",
|
"address": "817 Newton Street, Bannock, Wyoming, 1468"
|
||||||
"genres": [
|
|
||||||
"Action",
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"vote_count": 14661,
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg"
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -329,8 +251,7 @@ async fn search_with_settings_synonyms() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_ranking_rules() {
|
async fn search_with_settings_ranking_rules() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -339,33 +260,29 @@ async fn search_with_settings_ranking_rules() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"asc(vote_average)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(popularity)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"tagline",
|
"age",
|
||||||
"overview",
|
"color",
|
||||||
"cast",
|
"gender",
|
||||||
"director",
|
"email",
|
||||||
"producer",
|
"address",
|
||||||
"production_companies",
|
"about"
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"director",
|
"age",
|
||||||
"producer",
|
"gender",
|
||||||
"tagline",
|
"color",
|
||||||
"genres",
|
"email",
|
||||||
"id",
|
"phone",
|
||||||
"overview",
|
"address",
|
||||||
"vote_count",
|
"balance"
|
||||||
"vote_average",
|
|
||||||
"poster_path",
|
|
||||||
"popularity"
|
|
||||||
],
|
],
|
||||||
"stopWords": null,
|
"stopWords": null,
|
||||||
"synonyms": null,
|
"synonyms": null,
|
||||||
@ -374,69 +291,48 @@ async fn search_with_settings_ranking_rules() {
|
|||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=avangers&limit=3";
|
let query = "q=exarcitation&limit=3";
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 99861,
|
"balance": "$1,921.58",
|
||||||
"popularity": 33.938,
|
"age": 31,
|
||||||
"vote_average": 7.3,
|
"color": "green",
|
||||||
"title": "Avengers: Age of Ultron",
|
"name": "Harper Carson",
|
||||||
"tagline": "A New Age Has Come.",
|
"gender": "male",
|
||||||
"overview": "When Tony Stark tries to jumpstart a dormant peacekeeping program, things go awry and Earth’s Mightiest Heroes are put to the ultimate test as the fate of the planet hangs in the balance. As the villainous Ultron emerges, it is up to The Avengers to stop him from enacting his terrible plans, and soon uneasy alliances and unexpected action pave the way for an epic and unique global adventure.",
|
"email": "harpercarson@chorizon.com",
|
||||||
"director": "Joss Whedon",
|
"phone": "+1 (912) 430-3243",
|
||||||
"producer": "Kevin Feige",
|
"address": "883 Dennett Place, Knowlton, New Mexico, 9219"
|
||||||
"genres": [
|
|
||||||
"Action",
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg",
|
|
||||||
"vote_count": 14661
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"balance": "$1,706.13",
|
||||||
"popularity": 65.013,
|
"age": 27,
|
||||||
"vote_average": 8.3,
|
"color": "green",
|
||||||
"title": "Avengers: Infinity War",
|
"name": "Cherry Orr",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"gender": "female",
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
"email": "cherryorr@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (995) 479-3174",
|
||||||
"producer": "Kevin Feige",
|
"address": "442 Beverly Road, Ventress, New Mexico, 3361"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Action",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
|
|
||||||
"vote_count": 16056
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"balance": "$1,476.39",
|
||||||
"popularity": 38.659,
|
"age": 28,
|
||||||
"vote_average": 8.3,
|
"color": "brown",
|
||||||
"title": "Avengers: Endgame",
|
"name": "Maureen Dale",
|
||||||
"tagline": "Part of the journey is the end.",
|
"gender": "female",
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
"email": "maureendale@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (984) 538-3684",
|
||||||
"producer": "Kevin Feige",
|
"address": "817 Newton Street, Bannock, Wyoming, 1468"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction",
|
|
||||||
"Action"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg",
|
|
||||||
"vote_count": 10497
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let (response, _status_code) = server.search_get(query).await;
|
let (response, _status_code) = server.search_get(query).await;
|
||||||
|
println!("{}", response["hits"].clone());
|
||||||
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_searchable_attributes() {
|
async fn search_with_settings_searchable_attributes() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -445,92 +341,60 @@ async fn search_with_settings_searchable_attributes() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"desc(popularity)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(vote_average)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"tagline",
|
"age",
|
||||||
"overview",
|
"color",
|
||||||
"cast",
|
"gender",
|
||||||
"director",
|
"address",
|
||||||
"producer",
|
"about"
|
||||||
"production_companies",
|
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"director",
|
"age",
|
||||||
"producer",
|
"gender",
|
||||||
"tagline",
|
"color",
|
||||||
"genres",
|
"email",
|
||||||
"id",
|
"phone",
|
||||||
"overview",
|
"address",
|
||||||
"vote_count",
|
"balance"
|
||||||
"vote_average",
|
|
||||||
"poster_path",
|
|
||||||
"popularity"
|
|
||||||
],
|
],
|
||||||
"stopWords": null,
|
"stopWords": null,
|
||||||
"synonyms": null,
|
"synonyms": {
|
||||||
|
"exarcitation": [
|
||||||
|
"exercitation"
|
||||||
|
]
|
||||||
|
},
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
});
|
});
|
||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=avangers&limit=3";
|
let query = "q=Carol&limit=3";
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"balance": "$1,440.09",
|
||||||
"popularity": 65.013,
|
"age": 40,
|
||||||
"vote_average": 8.3,
|
"color": "blue",
|
||||||
"title": "Avengers: Infinity War",
|
"name": "Levy Whitley",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"gender": "male",
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
"email": "levywhitley@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (911) 458-2411",
|
||||||
"producer": "Kevin Feige",
|
"address": "187 Thomas Street, Hachita, North Carolina, 2989"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Action",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
|
|
||||||
"vote_count": 16056
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"balance": "$1,977.66",
|
||||||
"popularity": 38.659,
|
"age": 36,
|
||||||
"vote_average": 8.3,
|
"color": "brown",
|
||||||
"title": "Avengers: Endgame",
|
"name": "Combs Stanley",
|
||||||
"tagline": "Part of the journey is the end.",
|
"gender": "male",
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
"email": "combsstanley@chorizon.com",
|
||||||
"director": "Anthony Russo",
|
"phone": "+1 (827) 419-2053",
|
||||||
"producer": "Kevin Feige",
|
"address": "153 Beverley Road, Siglerville, South Carolina, 3666"
|
||||||
"genres": [
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction",
|
|
||||||
"Action"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg",
|
|
||||||
"vote_count": 10497
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 100402,
|
|
||||||
"popularity": 16.418,
|
|
||||||
"vote_average": 7.7,
|
|
||||||
"title": "Captain America: The Winter Soldier",
|
|
||||||
"tagline": "In heroes we trust.",
|
|
||||||
"overview": "After the cataclysmic events in New York with The Avengers, Steve Rogers, aka Captain America is living quietly in Washington, D.C. and trying to adjust to the modern world. But when a S.H.I.E.L.D. colleague comes under attack, Steve becomes embroiled in a web of intrigue that threatens to put the world at risk. Joining forces with the Black Widow, Captain America struggles to expose the ever-widening conspiracy while fighting off professional assassins sent to silence him at every turn. When the full scope of the villainous plot is revealed, Captain America and the Black Widow enlist the help of a new ally, the Falcon. However, they soon find themselves up against an unexpected and formidable enemy—the Winter Soldier.",
|
|
||||||
"director": "Anthony Russo",
|
|
||||||
"producer": "Kevin Feige",
|
|
||||||
"genres": [
|
|
||||||
"Action",
|
|
||||||
"Adventure",
|
|
||||||
"Science Fiction"
|
|
||||||
],
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/5TQ6YDmymBpnF005OyoB7ohZps9.jpg",
|
|
||||||
"vote_count": 11972
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -540,8 +404,7 @@ async fn search_with_settings_searchable_attributes() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_displayed_attributes() {
|
async fn search_with_settings_displayed_attributes() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -550,27 +413,25 @@ async fn search_with_settings_displayed_attributes() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"desc(popularity)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(vote_average)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"age",
|
||||||
"tagline",
|
"color",
|
||||||
"overview",
|
"gender",
|
||||||
"cast",
|
"address",
|
||||||
"director",
|
"about"
|
||||||
"producer",
|
|
||||||
"production_companies",
|
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"tagline",
|
"age",
|
||||||
"id",
|
"gender",
|
||||||
"overview",
|
"color",
|
||||||
"poster_path"
|
"email",
|
||||||
|
"phone"
|
||||||
],
|
],
|
||||||
"stopWords": null,
|
"stopWords": null,
|
||||||
"synonyms": null,
|
"synonyms": null,
|
||||||
@ -579,28 +440,31 @@ async fn search_with_settings_displayed_attributes() {
|
|||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=avangers&limit=3";
|
let query = "q=exercitation&limit=3";
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"age": 31,
|
||||||
"title": "Avengers: Infinity War",
|
"color": "green",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"name": "Harper Carson",
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
"gender": "male",
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
|
"email": "harpercarson@chorizon.com",
|
||||||
|
"phone": "+1 (912) 430-3243"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"age": 27,
|
||||||
"title": "Avengers: Endgame",
|
"color": "green",
|
||||||
"tagline": "Part of the journey is the end.",
|
"name": "Cherry Orr",
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
"gender": "female",
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
|
"email": "cherryorr@chorizon.com",
|
||||||
|
"phone": "+1 (995) 479-3174"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 99861,
|
"age": 28,
|
||||||
"title": "Avengers: Age of Ultron",
|
"color": "brown",
|
||||||
"tagline": "A New Age Has Come.",
|
"name": "Maureen Dale",
|
||||||
"overview": "When Tony Stark tries to jumpstart a dormant peacekeeping program, things go awry and Earth’s Mightiest Heroes are put to the ultimate test as the fate of the planet hangs in the balance. As the villainous Ultron emerges, it is up to The Avengers to stop him from enacting his terrible plans, and soon uneasy alliances and unexpected action pave the way for an epic and unique global adventure.",
|
"gender": "female",
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg"
|
"email": "maureendale@chorizon.com",
|
||||||
|
"phone": "+1 (984) 538-3684"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -610,8 +474,7 @@ async fn search_with_settings_displayed_attributes() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn search_with_settings_searchable_attributes_2() {
|
async fn search_with_settings_searchable_attributes_2() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
let config = json!({
|
let config = json!({
|
||||||
"rankingRules": [
|
"rankingRules": [
|
||||||
@ -620,27 +483,22 @@ async fn search_with_settings_searchable_attributes_2() {
|
|||||||
"proximity",
|
"proximity",
|
||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"desc(popularity)",
|
"desc(age)",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(vote_average)"
|
"desc(balance)"
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"tagline",
|
"age",
|
||||||
"overview",
|
"color",
|
||||||
"title",
|
"gender",
|
||||||
"cast",
|
"address",
|
||||||
"director",
|
"about"
|
||||||
"producer",
|
|
||||||
"production_companies",
|
|
||||||
"genres"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"tagline",
|
"age",
|
||||||
"id",
|
"gender"
|
||||||
"overview",
|
|
||||||
"poster_path"
|
|
||||||
],
|
],
|
||||||
"stopWords": null,
|
"stopWords": null,
|
||||||
"synonyms": null,
|
"synonyms": null,
|
||||||
@ -649,28 +507,22 @@ async fn search_with_settings_searchable_attributes_2() {
|
|||||||
|
|
||||||
server.update_all_settings(config).await;
|
server.update_all_settings(config).await;
|
||||||
|
|
||||||
let query = "q=avangers&limit=3";
|
let query = "q=exercitation&limit=3";
|
||||||
let expect = json!([
|
let expect = json!([
|
||||||
{
|
{
|
||||||
"id": 299536,
|
"age": 31,
|
||||||
"title": "Avengers: Infinity War",
|
"name": "Harper Carson",
|
||||||
"tagline": "An entire universe. Once and for all.",
|
"gender": "male"
|
||||||
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 299534,
|
"age": 27,
|
||||||
"title": "Avengers: Endgame",
|
"name": "Cherry Orr",
|
||||||
"tagline": "Part of the journey is the end.",
|
"gender": "female"
|
||||||
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 100402,
|
"age": 28,
|
||||||
"title": "Captain America: The Winter Soldier",
|
"name": "Maureen Dale",
|
||||||
"tagline": "In heroes we trust.",
|
"gender": "female"
|
||||||
"overview": "After the cataclysmic events in New York with The Avengers, Steve Rogers, aka Captain America is living quietly in Washington, D.C. and trying to adjust to the modern world. But when a S.H.I.E.L.D. colleague comes under attack, Steve becomes embroiled in a web of intrigue that threatens to put the world at risk. Joining forces with the Black Widow, Captain America struggles to expose the ever-widening conspiracy while fighting off professional assassins sent to silence him at every turn. When the full scope of the villainous plot is revealed, Captain America and the Black Widow enlist the help of a new ally, the Falcon. However, they soon find themselves up against an unexpected and formidable enemy—the Winter Soldier.",
|
|
||||||
"poster_path": "https://image.tmdb.org/t/p/w500/5TQ6YDmymBpnF005OyoB7ohZps9.jpg"
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
use assert_json_diff::assert_json_eq;
|
use assert_json_diff::assert_json_eq;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn write_all_and_delete() {
|
async fn write_all_and_delete() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
// 2 - Send the settings
|
// 2 - Send the settings
|
||||||
|
|
||||||
let body = json!({
|
let body = json!({
|
||||||
@ -18,40 +16,41 @@ async fn write_all_and_delete() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(registered)",
|
||||||
"desc(rank)",
|
"desc(age)",
|
||||||
],
|
],
|
||||||
"distinctAttribute": "movie_id",
|
"distinctAttribute": "id",
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"id",
|
"id",
|
||||||
"movie_id",
|
"name",
|
||||||
"title",
|
"color",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"phone",
|
||||||
"rank",
|
"address",
|
||||||
|
"registered",
|
||||||
|
"about"
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"registered",
|
||||||
"rank",
|
"age",
|
||||||
],
|
],
|
||||||
"stopWords": [
|
"stopWords": [
|
||||||
"the",
|
"ad",
|
||||||
"a",
|
"in",
|
||||||
"an",
|
"ut",
|
||||||
],
|
],
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"wolverine": ["xmen", "logan"],
|
"road": ["street", "avenue"],
|
||||||
"logan": ["wolverine"],
|
"street": ["avenue"],
|
||||||
},
|
},
|
||||||
"attributesForFaceting": ["title"],
|
"attributesForFaceting": ["name"],
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
server.update_all_settings(body.clone()).await;
|
server.update_all_settings(body.clone()).await;
|
||||||
|
|
||||||
// 3 - Get all settings and compare to the previous one
|
// 3 - Get all settings and compare to the previous one
|
||||||
@ -79,44 +78,40 @@ async fn write_all_and_delete() {
|
|||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"poster_path",
|
"address",
|
||||||
"director",
|
|
||||||
"id",
|
"id",
|
||||||
"production_companies",
|
"longitude",
|
||||||
"producer",
|
"phone",
|
||||||
"poster",
|
"age",
|
||||||
"movie_id",
|
"gender",
|
||||||
"vote_count",
|
"latitude",
|
||||||
"cast",
|
"email",
|
||||||
"release_date",
|
"about",
|
||||||
"vote_average",
|
"registered",
|
||||||
"rank",
|
"picture",
|
||||||
"genres",
|
"isActive",
|
||||||
"overview",
|
"tags",
|
||||||
"description",
|
"name",
|
||||||
"tagline",
|
"color",
|
||||||
"popularity",
|
"balance"
|
||||||
"title"
|
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"poster_path",
|
"address",
|
||||||
"poster",
|
|
||||||
"vote_count",
|
|
||||||
"id",
|
"id",
|
||||||
"movie_id",
|
"longitude",
|
||||||
"title",
|
"phone",
|
||||||
"rank",
|
"age",
|
||||||
"tagline",
|
"gender",
|
||||||
"cast",
|
"latitude",
|
||||||
"producer",
|
"email",
|
||||||
"production_companies",
|
"about",
|
||||||
"description",
|
"registered",
|
||||||
"director",
|
"picture",
|
||||||
"genres",
|
"isActive",
|
||||||
"release_date",
|
"tags",
|
||||||
"overview",
|
"name",
|
||||||
"vote_average",
|
"color",
|
||||||
"popularity"
|
"balance"
|
||||||
],
|
],
|
||||||
"stopWords": [],
|
"stopWords": [],
|
||||||
"synonyms": {},
|
"synonyms": {},
|
||||||
@ -129,8 +124,7 @@ async fn write_all_and_delete() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn write_all_and_update() {
|
async fn write_all_and_update() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
// 2 - Send the settings
|
// 2 - Send the settings
|
||||||
|
|
||||||
@ -142,36 +136,38 @@ async fn write_all_and_update() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(registered)",
|
||||||
"desc(rank)",
|
"desc(age)",
|
||||||
],
|
],
|
||||||
"distinctAttribute": "movie_id",
|
"distinctAttribute": "id",
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"uid",
|
"id",
|
||||||
"movie_id",
|
"name",
|
||||||
"title",
|
"color",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"phone",
|
||||||
"rank",
|
"address",
|
||||||
|
"registered",
|
||||||
|
"about"
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"registered",
|
||||||
"rank",
|
"age",
|
||||||
],
|
],
|
||||||
"stopWords": [
|
"stopWords": [
|
||||||
"the",
|
"ad",
|
||||||
"a",
|
"in",
|
||||||
"an",
|
"ut",
|
||||||
],
|
],
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"wolverine": ["xmen", "logan"],
|
"road": ["street", "avenue"],
|
||||||
"logan": ["wolverine"],
|
"street": ["avenue"],
|
||||||
},
|
},
|
||||||
"attributesForFaceting": ["title"],
|
"attributesForFaceting": ["name"],
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -193,25 +189,25 @@ async fn write_all_and_update() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(age)",
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"color",
|
||||||
"uid",
|
"age",
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"color",
|
||||||
"release_date",
|
"age",
|
||||||
"rank",
|
"registered",
|
||||||
"poster",
|
"picture",
|
||||||
],
|
],
|
||||||
"stopWords": [],
|
"stopWords": [],
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"wolverine": ["xmen", "logan"],
|
"road": ["street", "avenue"],
|
||||||
"logan": ["wolverine", "xmen"],
|
"street": ["avenue"],
|
||||||
},
|
},
|
||||||
"attributesForFaceting": ["title"],
|
"attributesForFaceting": ["title"],
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
@ -231,28 +227,28 @@ async fn write_all_and_update() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(age)",
|
||||||
],
|
],
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"color",
|
||||||
"uid",
|
"age",
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"color",
|
||||||
"release_date",
|
"age",
|
||||||
"rank",
|
"registered",
|
||||||
"poster",
|
"picture",
|
||||||
],
|
],
|
||||||
"stopWords": [],
|
"stopWords": [],
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"wolverine": ["xmen", "logan"],
|
"road": ["street", "avenue"],
|
||||||
"logan": ["wolverine", "xmen"],
|
"street": ["avenue"],
|
||||||
},
|
},
|
||||||
"attributesForFaceting": ["title"],
|
"attributesForFaceting": ["title"],
|
||||||
"acceptNewFields": false
|
"acceptNewFields": false,
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_json_eq!(expected, response, ordered: false);
|
assert_json_eq!(expected, response, ordered: false);
|
||||||
@ -260,9 +256,9 @@ async fn write_all_and_update() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_default_settings() {
|
async fn test_default_settings() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
});
|
});
|
||||||
server.create_index(body).await;
|
server.create_index(body).await;
|
||||||
|
|
||||||
@ -293,9 +289,9 @@ async fn test_default_settings() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_default_settings_2() {
|
async fn test_default_settings_2() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
"primaryKey": "id",
|
"primaryKey": "id",
|
||||||
});
|
});
|
||||||
server.create_index(body).await;
|
server.create_index(body).await;
|
||||||
@ -332,9 +328,9 @@ async fn test_default_settings_2() {
|
|||||||
// Test issue https://github.com/meilisearch/MeiliSearch/issues/516
|
// Test issue https://github.com/meilisearch/MeiliSearch/issues/516
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn write_setting_and_update_partial() {
|
async fn write_setting_and_update_partial() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
});
|
});
|
||||||
server.create_index(body).await;
|
server.create_index(body).await;
|
||||||
|
|
||||||
@ -342,20 +338,21 @@ async fn write_setting_and_update_partial() {
|
|||||||
|
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"uid",
|
"id",
|
||||||
"movie_id",
|
"name",
|
||||||
"title",
|
"color",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"phone",
|
||||||
"rank",
|
"address",
|
||||||
|
"about"
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"registered",
|
||||||
"rank",
|
"age",
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -371,18 +368,18 @@ async fn write_setting_and_update_partial() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(age)",
|
||||||
"desc(rank)",
|
"desc(registered)",
|
||||||
],
|
],
|
||||||
"distinctAttribute": "movie_id",
|
"distinctAttribute": "id",
|
||||||
"stopWords": [
|
"stopWords": [
|
||||||
"the",
|
"ad",
|
||||||
"a",
|
"in",
|
||||||
"an",
|
"ut",
|
||||||
],
|
],
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"wolverine": ["xmen", "logan"],
|
"road": ["street", "avenue"],
|
||||||
"logan": ["wolverine"],
|
"street": ["avenue"],
|
||||||
},
|
},
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
});
|
});
|
||||||
@ -399,34 +396,35 @@ async fn write_setting_and_update_partial() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(age)",
|
||||||
"desc(rank)",
|
"desc(registered)",
|
||||||
],
|
],
|
||||||
"distinctAttribute": "movie_id",
|
"distinctAttribute": "id",
|
||||||
"searchableAttributes": [
|
"searchableAttributes": [
|
||||||
"uid",
|
"id",
|
||||||
"movie_id",
|
"name",
|
||||||
"title",
|
"color",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"phone",
|
||||||
"rank",
|
"address",
|
||||||
|
"about"
|
||||||
],
|
],
|
||||||
"displayedAttributes": [
|
"displayedAttributes": [
|
||||||
"title",
|
"name",
|
||||||
"description",
|
"gender",
|
||||||
"poster",
|
"email",
|
||||||
"release_date",
|
"registered",
|
||||||
"rank",
|
"age",
|
||||||
],
|
],
|
||||||
"stopWords": [
|
"stopWords": [
|
||||||
"the",
|
"ad",
|
||||||
"a",
|
"in",
|
||||||
"an",
|
"ut",
|
||||||
],
|
],
|
||||||
"synonyms": {
|
"synonyms": {
|
||||||
"wolverine": ["xmen", "logan"],
|
"road": ["street", "avenue"],
|
||||||
"logan": ["wolverine"],
|
"street": ["avenue"],
|
||||||
},
|
},
|
||||||
"attributesForFaceting": [],
|
"attributesForFaceting": [],
|
||||||
"acceptNewFields": false,
|
"acceptNewFields": false,
|
||||||
|
@ -5,8 +5,7 @@ mod common;
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn write_all_and_delete() {
|
async fn write_all_and_delete() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
// 2 - Send the settings
|
// 2 - Send the settings
|
||||||
|
|
||||||
@ -17,8 +16,8 @@ async fn write_all_and_delete() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(registered)",
|
||||||
"desc(rank)",
|
"desc(age)",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
server.update_ranking_rules(body.clone()).await;
|
server.update_ranking_rules(body.clone()).await;
|
||||||
@ -51,8 +50,7 @@ async fn write_all_and_delete() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn write_all_and_update() {
|
async fn write_all_and_update() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
// 2 - Send the settings
|
// 2 - Send the settings
|
||||||
|
|
||||||
@ -63,8 +61,8 @@ async fn write_all_and_update() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(registered)",
|
||||||
"desc(rank)",
|
"desc(age)",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
server.update_ranking_rules(body.clone()).await;
|
server.update_ranking_rules(body.clone()).await;
|
||||||
@ -84,7 +82,7 @@ async fn write_all_and_update() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(registered)",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
server.update_ranking_rules(body).await;
|
server.update_ranking_rules(body).await;
|
||||||
@ -100,7 +98,7 @@ async fn write_all_and_update() {
|
|||||||
"attribute",
|
"attribute",
|
||||||
"wordsPosition",
|
"wordsPosition",
|
||||||
"exactness",
|
"exactness",
|
||||||
"desc(release_date)",
|
"desc(registered)",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert_json_eq!(expected, response, ordered: false);
|
assert_json_eq!(expected, response, ordered: false);
|
||||||
@ -108,9 +106,9 @@ async fn write_all_and_update() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn send_undefined_rule() {
|
async fn send_undefined_rule() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
"primaryKey": "id",
|
"primaryKey": "id",
|
||||||
});
|
});
|
||||||
server.create_index(body).await;
|
server.create_index(body).await;
|
||||||
@ -123,9 +121,9 @@ async fn send_undefined_rule() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn send_malformed_custom_rule() {
|
async fn send_malformed_custom_rule() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
"primaryKey": "id",
|
"primaryKey": "id",
|
||||||
});
|
});
|
||||||
server.create_index(body).await;
|
server.create_index(body).await;
|
||||||
@ -139,16 +137,16 @@ async fn send_malformed_custom_rule() {
|
|||||||
// Test issue https://github.com/meilisearch/MeiliSearch/issues/521
|
// Test issue https://github.com/meilisearch/MeiliSearch/issues/521
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn write_custom_ranking_and_index_documents() {
|
async fn write_custom_ranking_and_index_documents() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::with_uid("test");
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"uid": "movies",
|
"uid": "test",
|
||||||
"primaryKey": "id",
|
"primaryKey": "id",
|
||||||
});
|
});
|
||||||
server.create_index(body).await;
|
server.create_index(body).await;
|
||||||
|
|
||||||
// 1 - Add ranking rules with one custom ranking on a string
|
// 1 - Add ranking rules with one custom ranking on a string
|
||||||
|
|
||||||
let body = json!(["asc(title)", "typo"]);
|
let body = json!(["asc(name)", "typo"]);
|
||||||
|
|
||||||
server.update_ranking_rules(body).await;
|
server.update_ranking_rules(body).await;
|
||||||
|
|
||||||
@ -157,13 +155,13 @@ async fn write_custom_ranking_and_index_documents() {
|
|||||||
let body = json!([
|
let body = json!([
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"title": "Le Petit Prince",
|
"name": "Cherry Orr",
|
||||||
"author": "Exupéry"
|
"color": "green"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"title": "Pride and Prejudice",
|
"name": "Lucas Hess",
|
||||||
"author": "Jane Austen"
|
"color": "yellow"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -173,7 +171,7 @@ async fn write_custom_ranking_and_index_documents() {
|
|||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"author": "Exupéry"
|
"color": "green"
|
||||||
});
|
});
|
||||||
|
|
||||||
let (response, status_code) = server.get_document(1).await;
|
let (response, status_code) = server.get_document(1).await;
|
||||||
|
@ -5,8 +5,7 @@ mod common;
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn update_stop_words() {
|
async fn update_stop_words() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
// 1 - Get stop words
|
// 1 - Get stop words
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ async fn update_stop_words() {
|
|||||||
|
|
||||||
// 2 - Update stop words
|
// 2 - Update stop words
|
||||||
|
|
||||||
let body = json!(["the", "a"]);
|
let body = json!(["ut", "ea"]);
|
||||||
server.update_stop_words(body.clone()).await;
|
server.update_stop_words(body.clone()).await;
|
||||||
|
|
||||||
// 3 - Get all stop words and compare to the previous one
|
// 3 - Get all stop words and compare to the previous one
|
||||||
@ -35,22 +34,21 @@ async fn update_stop_words() {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn add_documents_and_stop_words() {
|
async fn add_documents_and_stop_words() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
let mut server = common::Server::test_server().await;
|
||||||
server.populate_movies().await;
|
|
||||||
|
|
||||||
// 2 - Update stop words
|
// 2 - Update stop words
|
||||||
|
|
||||||
let body = json!(["the", "of"]);
|
let body = json!(["ad", "in"]);
|
||||||
server.update_stop_words(body.clone()).await;
|
server.update_stop_words(body.clone()).await;
|
||||||
|
|
||||||
// 3 - Search for a document with stop words
|
// 3 - Search for a document with stop words
|
||||||
|
|
||||||
let (response, _status_code) = server.search_get("q=the%20mask").await;
|
let (response, _status_code) = server.search_get("q=in%20exercitation").await;
|
||||||
assert!(!response["hits"].as_array().unwrap().is_empty());
|
assert!(!response["hits"].as_array().unwrap().is_empty());
|
||||||
|
|
||||||
// 4 - Search for documents with *only* stop words
|
// 4 - Search for documents with *only* stop words
|
||||||
|
|
||||||
let (response, _status_code) = server.search_get("q=the%20of").await;
|
let (response, _status_code) = server.search_get("q=ad%20in").await;
|
||||||
assert!(response["hits"].as_array().unwrap().is_empty());
|
assert!(response["hits"].as_array().unwrap().is_empty());
|
||||||
|
|
||||||
// 5 - Delete all stop words
|
// 5 - Delete all stop words
|
||||||
|
Loading…
Reference in New Issue
Block a user