From 8fa6e8670ac49da984080fd6eecfc27de6ebb52b Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Thu, 29 May 2025 14:36:51 +0300 Subject: [PATCH 01/17] tests: Faster search::multi IT tests Use shared server + unique indices where possible Signed-off-by: Martin Tzvetanov Grigorov --- crates/meili-snap/src/lib.rs | 27 +- crates/meilisearch/tests/common/mod.rs | 2 +- crates/meilisearch/tests/search/multi/mod.rs | 1710 ++++++++---------- 3 files changed, 787 insertions(+), 952 deletions(-) diff --git a/crates/meili-snap/src/lib.rs b/crates/meili-snap/src/lib.rs index 1641a6335..e9fa94159 100644 --- a/crates/meili-snap/src/lib.rs +++ b/crates/meili-snap/src/lib.rs @@ -43,23 +43,20 @@ pub fn default_snapshot_settings_for_test<'a>( } } + fn uuid_in_index_uid_redaction(content: Content, _content_path: ContentPath) -> Content { + match &content { + Content::String(s) => match uuid::Uuid::parse_str(s) { + Ok(_) => Content::String("[uuid]".to_owned()), + Err(_) => content, + }, + _ => content, + } + } + settings.add_dynamic_redaction(".message", uuid_in_message_redaction); settings.add_dynamic_redaction(".error.message", uuid_in_message_redaction); - settings.add_dynamic_redaction(".indexUid", |content, _content_path| match &content { - Content::String(s) => match uuid::Uuid::parse_str(s) { - Ok(_) => Content::String("[uuid]".to_owned()), - Err(_) => content, - }, - _ => content, - }); - - settings.add_dynamic_redaction(".error.message", |content, _content_path| match &content { - Content::String(s) => { - let uuid_replaced = UUID_IN_MESSAGE_RE.replace_all(s, "$before[uuid]$after"); - Content::String(uuid_replaced.to_string()) - } - _ => content, - }); + settings.add_dynamic_redaction(".indexUid", uuid_in_index_uid_redaction); + settings.add_dynamic_redaction(".**.indexUid", uuid_in_index_uid_redaction); let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name); let test_name = test_name.rsplit("::").next().unwrap().to_owned(); diff --git a/crates/meilisearch/tests/common/mod.rs b/crates/meilisearch/tests/common/mod.rs index 373f89f78..1a73a7532 100644 --- a/crates/meilisearch/tests/common/mod.rs +++ b/crates/meilisearch/tests/common/mod.rs @@ -269,7 +269,7 @@ pub async fn shared_index_with_score_documents() -> &'static Index<'static, Shar static INDEX: OnceCell> = OnceCell::const_new(); INDEX.get_or_init(|| async { let server = Server::new_shared(); - let index = server._index("SCORE_DOCUMENTS").to_shared(); + let index = server._index("SHARED_SCORE_DOCUMENTS").to_shared(); let documents = SCORE_DOCUMENTS.clone(); let (response, _code) = index._add_documents(documents, None).await; index.wait_task(response.uid()).await.succeeded(); diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 8a83fd3c0..8eea27792 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1,7 +1,10 @@ use meili_snap::{json_string, snapshot}; use super::{DOCUMENTS, FRUITS_DOCUMENTS, NESTED_DOCUMENTS}; -use crate::common::Server; +use crate::common::{ + shared_index_with_documents, shared_index_with_nested_documents, + shared_index_with_score_documents, Server, +}; use crate::json; use crate::search::{SCORE_DOCUMENTS, VECTOR_DOCUMENTS}; @@ -9,7 +12,7 @@ mod proxy; #[actix_rt::test] async fn search_empty_list() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server.multi_search(json!({"queries": []})).await; snapshot!(code, @"200 OK"); @@ -22,7 +25,7 @@ async fn search_empty_list() { #[actix_rt::test] async fn federation_empty_list() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server.multi_search(json!({"federation": {}, "queries": []})).await; snapshot!(code, @"200 OK"); @@ -39,7 +42,7 @@ async fn federation_empty_list() { #[actix_rt::test] async fn search_json_object() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server.multi_search(json!({})).await; snapshot!(code, @"400 Bad Request"); @@ -55,7 +58,7 @@ async fn search_json_object() { #[actix_rt::test] async fn federation_no_queries() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server.multi_search(json!({"federation": {}})).await; snapshot!(code, @"400 Bad Request"); @@ -71,7 +74,7 @@ async fn federation_no_queries() { #[actix_rt::test] async fn search_json_array() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server.multi_search(json!([])).await; snapshot!(code, @"400 Bad Request"); @@ -87,24 +90,20 @@ async fn search_json_array() { #[actix_rt::test] async fn simple_search_single_index() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid": "test", "q": "glass"}, - {"indexUid": "test", "q": "captain"}, + {"indexUid": index.uid, "q": "glass"}, + {"indexUid": index.uid, "q": "captain"}, ]})) .await; snapshot!(code, @"200 OK"); insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" [ { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "hits": [ { "title": "Gläss", @@ -122,7 +121,7 @@ async fn simple_search_single_index() { "estimatedTotalHits": 1 }, { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "hits": [ { "title": "Captain Marvel", @@ -145,16 +144,12 @@ async fn simple_search_single_index() { #[actix_rt::test] async fn federation_single_search_single_index() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, + {"indexUid" : index.uid, "q": "glass"}, ]})) .await; snapshot!(code, @"200 OK"); @@ -169,7 +164,7 @@ async fn federation_single_search_single_index() { "red" ], "_federation": { - "indexUid": "test", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -185,19 +180,15 @@ async fn federation_single_search_single_index() { #[actix_rt::test] async fn federation_multiple_search_single_index() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = SCORE_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid": "test", "q": "the bat"}, - {"indexUid": "test", "q": "badman returns"}, - {"indexUid" : "test", "q": "batman"}, - {"indexUid": "test", "q": "batman returns"}, + {"indexUid": index.uid, "q": "the bat"}, + {"indexUid": index.uid, "q": "badman returns"}, + {"indexUid" : index.uid, "q": "batman"}, + {"indexUid": index.uid, "q": "batman returns"}, ]})) .await; snapshot!(code, @"200 OK"); @@ -260,17 +251,13 @@ async fn federation_multiple_search_single_index() { #[actix_rt::test] async fn federation_two_search_single_index() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "test", "q": "captain"}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": index.uid, "q": "captain"}, ]})) .await; snapshot!(code, @"200 OK"); @@ -285,7 +272,7 @@ async fn federation_two_search_single_index() { "red" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -298,7 +285,7 @@ async fn federation_two_search_single_index() { "blue" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 } @@ -314,12 +301,7 @@ async fn federation_two_search_single_index() { #[actix_rt::test] async fn simple_search_missing_index_uid() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); let (response, code) = server .multi_search(json!({"queries": [ @@ -339,12 +321,7 @@ async fn simple_search_missing_index_uid() { #[actix_rt::test] async fn federation_simple_search_missing_index_uid() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ @@ -364,12 +341,7 @@ async fn federation_simple_search_missing_index_uid() { #[actix_rt::test] async fn simple_search_illegal_index_uid() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); let (response, code) = server .multi_search(json!({"queries": [ @@ -389,12 +361,7 @@ async fn simple_search_illegal_index_uid() { #[actix_rt::test] async fn federation_search_illegal_index_uid() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ @@ -414,29 +381,22 @@ async fn federation_search_illegal_index_uid() { #[actix_rt::test] async fn simple_search_two_indexes() { - let server = Server::new().await; - let index = server.index("test"); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (add_task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(add_task.uid()).await.succeeded(); + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti"}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": nested_index.uid, "q": "pésti"}, ]})) .await; snapshot!(code, @"200 OK"); insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" [ { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "hits": [ { "title": "Gläss", @@ -454,7 +414,7 @@ async fn simple_search_two_indexes() { "estimatedTotalHits": 1 }, { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "hits": [ { "id": 852, @@ -500,22 +460,14 @@ async fn simple_search_two_indexes() { #[actix_rt::test] async fn federation_two_search_two_indexes() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti"}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": nested_index.uid, "q": "pésti"}, ]})) .await; snapshot!(code, @"200 OK"); @@ -530,7 +482,7 @@ async fn federation_two_search_two_indexes() { "red" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -551,7 +503,7 @@ async fn federation_two_search_two_indexes() { ], "cattos": "pésti", "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -571,7 +523,7 @@ async fn federation_two_search_two_indexes() { "pestiféré" ], "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.7803030303030303 } @@ -587,36 +539,26 @@ async fn federation_two_search_two_indexes() { #[actix_rt::test] async fn federation_multiple_search_multiple_indexes() { - let server = Server::new().await; - let index = server.index("test"); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let nested_index = shared_index_with_nested_documents().await; - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("score"); - let documents = SCORE_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let score_index = shared_index_with_score_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid" : "test", "q": "captain"}, - {"indexUid": "nested", "q": "pésti"}, - {"indexUid" : "test", "q": "Escape"}, - {"indexUid": "nested", "q": "jean"}, - {"indexUid": "score", "q": "jean"}, - {"indexUid": "test", "q": "the bat"}, - {"indexUid": "score", "q": "the bat"}, - {"indexUid": "score", "q": "badman returns"}, - {"indexUid" : "score", "q": "batman"}, - {"indexUid": "score", "q": "batman returns"}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid" : index.uid, "q": "captain"}, + {"indexUid": nested_index.uid, "q": "pésti"}, + {"indexUid" : index.uid, "q": "Escape"}, + {"indexUid": nested_index.uid, "q": "jean"}, + {"indexUid": score_index.uid, "q": "jean"}, + {"indexUid": index.uid, "q": "the bat"}, + {"indexUid": score_index.uid, "q": "the bat"}, + {"indexUid": score_index.uid, "q": "badman returns"}, + {"indexUid" : score_index.uid, "q": "batman"}, + {"indexUid": score_index.uid, "q": "batman returns"}, ]})) .await; snapshot!(code, @"200 OK"); @@ -631,7 +573,7 @@ async fn federation_multiple_search_multiple_indexes() { "red" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -652,7 +594,7 @@ async fn federation_multiple_search_multiple_indexes() { ], "cattos": "pésti", "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -661,7 +603,7 @@ async fn federation_multiple_search_multiple_indexes() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 1.0 } @@ -670,7 +612,7 @@ async fn federation_multiple_search_multiple_indexes() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 10, "weightedRankingScore": 1.0 } @@ -683,7 +625,7 @@ async fn federation_multiple_search_multiple_indexes() { "blue" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 } @@ -696,7 +638,7 @@ async fn federation_multiple_search_multiple_indexes() { "red" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 0.9848484848484848 } @@ -720,7 +662,7 @@ async fn federation_multiple_search_multiple_indexes() { "gomez" ], "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 4, "weightedRankingScore": 0.9848484848484848 } @@ -729,7 +671,7 @@ async fn federation_multiple_search_multiple_indexes() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -738,7 +680,7 @@ async fn federation_multiple_search_multiple_indexes() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -758,7 +700,7 @@ async fn federation_multiple_search_multiple_indexes() { "pestiféré" ], "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.7803030303030303 } @@ -767,7 +709,7 @@ async fn federation_multiple_search_multiple_indexes() { "title": "Badman", "id": "E", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 8, "weightedRankingScore": 0.5 } @@ -780,7 +722,7 @@ async fn federation_multiple_search_multiple_indexes() { "red" ], "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 6, "weightedRankingScore": 0.4166666666666667 } @@ -796,16 +738,12 @@ async fn federation_multiple_search_multiple_indexes() { #[actix_rt::test] async fn search_one_index_doesnt_exist() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass"}, + {"indexUid" : index.uid, "q": "glass"}, {"indexUid": "nested", "q": "pésti"}, ]})) .await; @@ -822,16 +760,12 @@ async fn search_one_index_doesnt_exist() { #[actix_rt::test] async fn federation_one_index_doesnt_exist() { - let server = Server::new().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, + {"indexUid" : index.uid, "q": "glass"}, {"indexUid": "nested", "q": "pésti"}, ]})) .await; @@ -848,7 +782,7 @@ async fn federation_one_index_doesnt_exist() { #[actix_rt::test] async fn search_multiple_indexes_dont_exist() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server .multi_search(json!({"queries": [ @@ -869,7 +803,7 @@ async fn search_multiple_indexes_dont_exist() { #[actix_rt::test] async fn federation_multiple_indexes_dont_exist() { - let server = Server::new().await; + let server = Server::new_shared(); let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ @@ -892,25 +826,17 @@ async fn federation_multiple_indexes_dont_exist() { #[actix_rt::test] async fn search_one_query_error() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass", "facets": ["title"]}, - {"indexUid": "nested", "q": "pésti"}, + {"indexUid" : index.uid, "q": "glass", "facets": ["title"]}, + {"indexUid": nested_index.uid, "q": "pésti"}, ]})) .await; + dbg!(&response); snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { @@ -924,29 +850,21 @@ async fn search_one_query_error() { #[actix_rt::test] async fn federation_one_query_error() { - let server = Server::new().await; + let server = Server::new_shared(); + let index = shared_index_with_documents().await; - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti", "filter": ["title = toto"]}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": nested_index.uid, "q": "pésti", "filter": ["title = toto"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `nested`: Attribute `title` is not filterable. This index does not have configured filterable attributes.\n1:6 title = toto", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `title` is not filterable. This index does not have configured filterable attributes.\n1:6 title = toto", "code": "invalid_search_filter", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_filter" @@ -956,23 +874,14 @@ async fn federation_one_query_error() { #[actix_rt::test] async fn federation_one_query_sort_error() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti", "sort": ["doggos:desc"]}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -988,25 +897,17 @@ async fn federation_one_query_sort_error() { #[actix_rt::test] async fn search_multiple_query_errors() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass", "facets": ["title"]}, - {"indexUid": "nested", "q": "pésti", "facets": ["doggos"]}, + {"indexUid" : index.uid, "q": "glass", "facets": ["title"]}, + {"indexUid": nested_index.uid, "q": "pésti", "facets": ["doggos"]}, ]})) .await; + dbg!(&response); snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { @@ -1020,23 +921,14 @@ async fn search_multiple_query_errors() { #[actix_rt::test] async fn federation_multiple_query_errors() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass", "filter": ["title = toto"]}, - {"indexUid": "nested", "q": "pésti", "filter": ["doggos IN [intel, kefir]"]}, + {"indexUid" : index.uid, "q": "glass", "filter": ["title = toto"]}, + {"indexUid": nested_index.uid, "q": "pésti", "filter": ["doggos IN [intel, kefir]"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -1052,29 +944,20 @@ async fn federation_multiple_query_errors() { #[actix_rt::test] async fn federation_multiple_query_sort_errors() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass", "sort": ["title:desc"]}, - {"indexUid": "nested", "q": "pésti", "sort": ["doggos:desc"]}, + {"indexUid" : index.uid, "q": "glass", "sort": ["title:desc"]}, + {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Index `test`: Attribute `title` is not sortable. This index does not have configured sortable attributes.", + "message": "Inside `.queries[0]`: Index `SHARED_DOCUMENTS`: Attribute `title` is not sortable. This index does not have configured sortable attributes.", "code": "invalid_search_sort", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_sort" @@ -1084,30 +967,21 @@ async fn federation_multiple_query_sort_errors() { #[actix_rt::test] async fn federation_multiple_query_errors_interleaved() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti", "filter": ["doggos IN [intel, kefir]"]}, - {"indexUid" : "test", "q": "glass", "filter": ["title = toto"]}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": nested_index.uid, "q": "pésti", "filter": ["doggos IN [intel, kefir]"]}, + {"indexUid" : index.uid, "q": "glass", "filter": ["title = toto"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `nested`: Attribute `doggos` is not filterable. This index does not have configured filterable attributes.\n1:7 doggos IN [intel, kefir]", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `doggos` is not filterable. This index does not have configured filterable attributes.\n1:7 doggos IN [intel, kefir]", "code": "invalid_search_filter", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_filter" @@ -1117,30 +991,21 @@ async fn federation_multiple_query_errors_interleaved() { #[actix_rt::test] async fn federation_multiple_query_sort_errors_interleaved() { - let server = Server::new().await; - - let index = server.index("test"); - - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let server = Server::new_shared(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti", "sort": ["doggos:desc"]}, - {"indexUid" : "test", "q": "glass", "sort": ["title:desc"]}, + {"indexUid" : index.uid, "q": "glass"}, + {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, + {"indexUid" : index.uid, "q": "glass", "sort": ["title:desc"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `nested`: Attribute `doggos` is not sortable. This index does not have configured sortable attributes.", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `doggos` is not sortable. This index does not have configured sortable attributes.", "code": "invalid_search_sort", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_sort" @@ -1150,9 +1015,8 @@ async fn federation_multiple_query_sort_errors_interleaved() { #[actix_rt::test] async fn federation_filter() { - let server = Server::new().await; - - let index = server.index("fruits"); + let server = Server::new_shared(); + let index = server.unique_index(); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -1167,12 +1031,12 @@ async fn federation_filter() { let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red", "filter": "BOOST = true", "showRankingScore": true, "federationOptions": {"weight": 3.0}}, - {"indexUid": "fruits", "q": "apple red", "showRankingScore": true}, + {"indexUid" : index.uid, "q": "apple red", "filter": "BOOST = true", "showRankingScore": true, "federationOptions": {"weight": 3.0}}, + {"indexUid": index.uid, "q": "apple red", "showRankingScore": true}, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -1180,7 +1044,7 @@ async fn federation_filter() { "id": "red-delicious-boosted", "BOOST": true, "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 2.7281746031746033 }, @@ -1191,7 +1055,7 @@ async fn federation_filter() { "id": "green-apple-boosted", "BOOST": true, "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.318181818181818 }, @@ -1201,7 +1065,7 @@ async fn federation_filter() { "name": "Red apple gala", "id": "red-apple-gala", "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.953042328042328 }, @@ -1218,9 +1082,8 @@ async fn federation_filter() { #[actix_rt::test] async fn federation_sort_same_indexes_same_criterion_same_direction() { - let server = Server::new().await; - - let index = server.index("nested"); + let server = Server::new_shared(); + let index = server.unique_index(); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -1244,12 +1107,12 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { // two identical placeholder search should have all results from first query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -1268,7 +1131,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { ], "cattos": "pésti", "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1282,7 +1145,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "enigma" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1303,7 +1166,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "pestiféré" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1328,7 +1191,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "gomez" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1345,12 +1208,12 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { // mix and match query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "pésti", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "jean", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "pésti", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "jean", "sort": ["mother:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -1369,7 +1232,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { ], "cattos": "pésti", "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1390,7 +1253,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "pestiféré" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.7803030303030303 }, @@ -1415,7 +1278,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "gomez" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 }, @@ -1432,9 +1295,8 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { #[actix_rt::test] async fn federation_sort_same_indexes_same_criterion_opposite_direction() { - let server = Server::new().await; - - let index = server.index("nested"); + let server = Server::new_shared(); + let index = server.unique_index(); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -1458,14 +1320,14 @@ async fn federation_sort_same_indexes_same_criterion_opposite_direction() { // two identical placeholder search should have all results from first query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "", "sort": ["mother:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["mother:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested.rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested.rankingRules[0]`: descending sort rule(s) on field `mother`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `mother`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -1475,14 +1337,14 @@ async fn federation_sort_same_indexes_same_criterion_opposite_direction() { // mix and match query: should be ranked by ranking score let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "pésti", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "jean", "sort": ["mother:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "pésti", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "jean", "sort": ["mother:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested.rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested.rankingRules[0]`: descending sort rule(s) on field `mother`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `mother`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -1492,9 +1354,8 @@ async fn federation_sort_same_indexes_same_criterion_opposite_direction() { #[actix_rt::test] async fn federation_sort_same_indexes_different_criterion_same_direction() { - let server = Server::new().await; - - let index = server.index("nested"); + let server = Server::new_shared(); + let index = server.unique_index(); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -1518,12 +1379,12 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { // return mothers and fathers ordered accross fields. let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "", "sort": ["father:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["father:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -1542,7 +1403,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { ], "cattos": "pésti", "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1567,7 +1428,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "gomez" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1581,7 +1442,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "enigma" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1602,7 +1463,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "pestiféré" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1619,13 +1480,13 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { // mix and match query: will be sorted across mother and father names let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "pésti", "sort": ["mother:desc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "jean-bap", "sort": ["father:desc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "jea", "sort": ["father:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "pésti", "sort": ["mother:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "jean-bap", "sort": ["father:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "jea", "sort": ["father:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -1643,7 +1504,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "pestiféré" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.7803030303030303 }, @@ -1665,7 +1526,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { ], "cattos": "pésti", "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1690,7 +1551,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "gomez" ], "_federation": { - "indexUid": "nested", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9991181657848324 }, @@ -1707,9 +1568,8 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { #[actix_rt::test] async fn federation_sort_same_indexes_different_criterion_opposite_direction() { - let server = Server::new().await; - - let index = server.index("nested"); + let server = Server::new_shared(); + let index = server.unique_index(); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -1733,14 +1593,14 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { // two identical placeholder search should have all results from first query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "", "sort": ["father:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "", "sort": ["father:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested.rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested.rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -1750,8 +1610,8 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { // mix and match query: should be ranked by ranking score let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "nested", "q": "pésti", "sort": ["mother:asc"], "showRankingScore": true }, - {"indexUid" : "nested", "q": "jean", "sort": ["father:desc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "pésti", "sort": ["mother:asc"], "showRankingScore": true }, + {"indexUid" : index.uid, "q": "jean", "sort": ["father:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -1767,15 +1627,14 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { #[actix_rt::test] async fn federation_sort_different_indexes_same_criterion_same_direction() { - let server = Server::new().await; - - let index = server.index("movies"); + let server = Server::new_shared(); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -1788,15 +1647,15 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -1809,24 +1668,24 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); // return titles ordered accross indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { "title": "Badman", "id": "E", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1836,7 +1695,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1846,7 +1705,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1856,7 +1715,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1866,7 +1725,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1880,7 +1739,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1894,7 +1753,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1908,7 +1767,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1922,7 +1781,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1936,7 +1795,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1953,13 +1812,13 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { // mix and match query: will be sorted across indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "batman", "q": "badman returns", "sort": ["title:desc"], "showRankingScore": true }, - {"indexUid" : "movies", "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "the bat", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "badman returns", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "the bat", "sort": ["title:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -1970,7 +1829,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 }, @@ -1980,7 +1839,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -1990,7 +1849,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -2000,7 +1859,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8317901234567902 }, @@ -2010,7 +1869,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.23106060606060605 }, @@ -2020,7 +1879,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Badman", "id": "E", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.5 }, @@ -2037,15 +1896,15 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { #[actix_rt::test] async fn federation_sort_different_ranking_rules() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("movies"); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -2058,15 +1917,15 @@ async fn federation_sort_different_ranking_rules() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -2079,24 +1938,24 @@ async fn federation_sort_different_ranking_rules() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); // return titles ordered accross indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { "title": "Badman", "id": "E", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2106,7 +1965,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2116,7 +1975,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2126,7 +1985,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2136,7 +1995,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2150,7 +2009,7 @@ async fn federation_sort_different_ranking_rules() { "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2164,7 +2023,7 @@ async fn federation_sort_different_ranking_rules() { "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2178,7 +2037,7 @@ async fn federation_sort_different_ranking_rules() { "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2192,7 +2051,7 @@ async fn federation_sort_different_ranking_rules() { "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2206,7 +2065,7 @@ async fn federation_sort_different_ranking_rules() { "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2223,15 +2082,15 @@ async fn federation_sort_different_ranking_rules() { // mix and match query: order difficult to understand let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "batman", "q": "badman returns", "sort": ["title:desc"], "showRankingScore": true }, - {"indexUid" : "movies", "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "the bat", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "badman returns", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "the bat", "sort": ["title:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `batman.rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `movies.rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `[uuid].rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2241,15 +2100,15 @@ async fn federation_sort_different_ranking_rules() { #[actix_rt::test] async fn federation_sort_different_indexes_same_criterion_opposite_direction() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("movies"); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -2262,15 +2121,15 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -2283,19 +2142,19 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); // all results from query 0 let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "", "sort": ["title:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman.rankingRules[0]`: descending sort rule(s) on field `title`\n 2. `queries[0].sort[0]`, `movies.rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n 2. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2305,15 +2164,15 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { // mix and match query: will be sorted by ranking score let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "batman", "q": "badman returns", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "movies", "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "the bat", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "badman returns", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "the bat", "sort": ["title:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `batman.rankingRules[0]`: ascending sort rule(s) on field `title`\n 2. `queries[1].sort[0]`, `movies.rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2323,15 +2182,15 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { #[actix_rt::test] async fn federation_sort_different_indexes_different_criterion_same_direction() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("movies"); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -2344,15 +2203,15 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["id"], "rankingRules": [ @@ -2365,24 +2224,24 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); // return titles ordered accross indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "", "sort": ["id:asc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "", "sort": ["id:asc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2392,7 +2251,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2402,7 +2261,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2416,7 +2275,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2426,7 +2285,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman", "id": "D", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2436,7 +2295,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Badman", "id": "E", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2450,7 +2309,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2464,7 +2323,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2478,7 +2337,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "red" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2492,7 +2351,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2509,20 +2368,20 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() // mix and match query: will be sorted across indexes and criterion let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "batman", "q": "badman returns", "sort": ["id:desc"], "showRankingScore": true }, - {"indexUid" : "movies", "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "the bat", "sort": ["id:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "badman returns", "sort": ["id:desc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "captain", "sort": ["title:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "the bat", "sort": ["id:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Badman", "id": "E", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.5 }, @@ -2532,7 +2391,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman", "id": "D", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.23106060606060605 }, @@ -2546,7 +2405,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "blue" ], "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 }, @@ -2556,7 +2415,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8317901234567902 }, @@ -2566,7 +2425,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -2576,7 +2435,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -2593,15 +2452,15 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() #[actix_rt::test] async fn federation_sort_different_indexes_different_criterion_opposite_direction() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("movies"); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "rankingRules": [ @@ -2614,15 +2473,15 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["id"], "rankingRules": [ @@ -2635,19 +2494,19 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); // all results from query 0 first let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "", "sort": ["id:desc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "", "sort": ["id:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman.rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[0].sort[0]`, `movies.rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2657,15 +2516,15 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio // mix and match query: more or less by ranking score let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "batman", "q": "badman returns", "sort": ["id:desc"], "showRankingScore": true }, - {"indexUid" : "movies", "q": "captain", "sort": ["title:asc"], "showRankingScore": true }, - {"indexUid" : "batman", "q": "the bat", "sort": ["id:desc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "badman returns", "sort": ["id:desc"], "showRankingScore": true }, + {"indexUid" : movies_index.uid, "q": "captain", "sort": ["title:asc"], "showRankingScore": true }, + {"indexUid" : batman_index.uid, "q": "the bat", "sort": ["id:desc"], "showRankingScore": true }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `batman.rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[1].sort[0]`, `movies.rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2675,36 +2534,25 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio #[actix_rt::test] async fn federation_limit_offset() { - let server = Server::new().await; - let index = server.index("test"); + let server = Server::new_shared(); + let index = server.unique_index(); + let nested_index = shared_index_with_nested_documents().await; + let score_index = shared_index_with_score_documents().await; - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("score"); - let documents = SCORE_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); { let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -2714,7 +2562,7 @@ async fn federation_limit_offset() { { "title": "Gläss", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -2722,7 +2570,7 @@ async fn federation_limit_offset() { { "id": 852, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -2730,7 +2578,7 @@ async fn federation_limit_offset() { { "title": "Batman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 1.0 } @@ -2738,7 +2586,7 @@ async fn federation_limit_offset() { { "title": "Batman Returns", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 10, "weightedRankingScore": 1.0 } @@ -2746,7 +2594,7 @@ async fn federation_limit_offset() { { "title": "Captain Marvel", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 } @@ -2754,7 +2602,7 @@ async fn federation_limit_offset() { { "title": "Escape Room", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 0.9848484848484848 } @@ -2762,7 +2610,7 @@ async fn federation_limit_offset() { { "id": 951, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 4, "weightedRankingScore": 0.9848484848484848 } @@ -2770,7 +2618,7 @@ async fn federation_limit_offset() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -2778,7 +2626,7 @@ async fn federation_limit_offset() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -2786,7 +2634,7 @@ async fn federation_limit_offset() { { "id": 654, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.7803030303030303 } @@ -2794,7 +2642,7 @@ async fn federation_limit_offset() { { "title": "Badman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 8, "weightedRankingScore": 0.5 } @@ -2802,7 +2650,7 @@ async fn federation_limit_offset() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 6, "weightedRankingScore": 0.4166666666666667 } @@ -2819,17 +2667,17 @@ async fn federation_limit_offset() { { let (response, code) = server .multi_search(json!({"federation": {"limit": 1}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -2839,7 +2687,7 @@ async fn federation_limit_offset() { { "title": "Gläss", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -2856,17 +2704,17 @@ async fn federation_limit_offset() { { let (response, code) = server .multi_search(json!({"federation": {"offset": 2}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -2876,7 +2724,7 @@ async fn federation_limit_offset() { { "title": "Batman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 1.0 } @@ -2884,7 +2732,7 @@ async fn federation_limit_offset() { { "title": "Batman Returns", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 10, "weightedRankingScore": 1.0 } @@ -2892,7 +2740,7 @@ async fn federation_limit_offset() { { "title": "Captain Marvel", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 } @@ -2900,7 +2748,7 @@ async fn federation_limit_offset() { { "title": "Escape Room", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 0.9848484848484848 } @@ -2908,7 +2756,7 @@ async fn federation_limit_offset() { { "id": 951, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 4, "weightedRankingScore": 0.9848484848484848 } @@ -2916,7 +2764,7 @@ async fn federation_limit_offset() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -2924,7 +2772,7 @@ async fn federation_limit_offset() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -2932,7 +2780,7 @@ async fn federation_limit_offset() { { "id": 654, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.7803030303030303 } @@ -2940,7 +2788,7 @@ async fn federation_limit_offset() { { "title": "Badman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 8, "weightedRankingScore": 0.5 } @@ -2948,7 +2796,7 @@ async fn federation_limit_offset() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 6, "weightedRankingScore": 0.4166666666666667 } @@ -2965,17 +2813,17 @@ async fn federation_limit_offset() { { let (response, code) = server .multi_search(json!({"federation": {"offset": 12}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -2993,36 +2841,26 @@ async fn federation_limit_offset() { #[actix_rt::test] async fn federation_formatting() { - let server = Server::new().await; - let index = server.index("test"); + let server = Server::new_shared(); + let index = server.unique_index(); - let documents = DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); + let nested_index = server.unique_index(); + let score_index = server.unique_index(); - let index = server.index("nested"); - let documents = NESTED_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); - - let index = server.index("score"); - let documents = SCORE_DOCUMENTS.clone(); - let (task, _status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await.succeeded(); { let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"], "attributesToHighlight": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -3032,7 +2870,7 @@ async fn federation_formatting() { { "title": "Gläss", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -3043,7 +2881,7 @@ async fn federation_formatting() { { "id": 852, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -3051,7 +2889,7 @@ async fn federation_formatting() { { "title": "Batman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 1.0 }, @@ -3062,7 +2900,7 @@ async fn federation_formatting() { { "title": "Batman Returns", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 10, "weightedRankingScore": 1.0 }, @@ -3073,7 +2911,7 @@ async fn federation_formatting() { { "title": "Captain Marvel", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 }, @@ -3084,7 +2922,7 @@ async fn federation_formatting() { { "title": "Escape Room", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 0.9848484848484848 }, @@ -3095,7 +2933,7 @@ async fn federation_formatting() { { "id": 951, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 4, "weightedRankingScore": 0.9848484848484848 } @@ -3103,7 +2941,7 @@ async fn federation_formatting() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 }, @@ -3114,7 +2952,7 @@ async fn federation_formatting() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 }, @@ -3125,7 +2963,7 @@ async fn federation_formatting() { { "id": 654, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.7803030303030303 } @@ -3133,7 +2971,7 @@ async fn federation_formatting() { { "title": "Badman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 8, "weightedRankingScore": 0.5 }, @@ -3144,7 +2982,7 @@ async fn federation_formatting() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 6, "weightedRankingScore": 0.4166666666666667 }, @@ -3164,17 +3002,17 @@ async fn federation_formatting() { { let (response, code) = server .multi_search(json!({"federation": {"limit": 1}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -3184,7 +3022,7 @@ async fn federation_formatting() { { "title": "Gläss", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -3201,17 +3039,17 @@ async fn federation_formatting() { { let (response, code) = server .multi_search(json!({"federation": {"offset": 2}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -3221,7 +3059,7 @@ async fn federation_formatting() { { "title": "Batman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 1.0 } @@ -3229,7 +3067,7 @@ async fn federation_formatting() { { "title": "Batman Returns", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 10, "weightedRankingScore": 1.0 } @@ -3237,7 +3075,7 @@ async fn federation_formatting() { { "title": "Captain Marvel", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 } @@ -3245,7 +3083,7 @@ async fn federation_formatting() { { "title": "Escape Room", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 0.9848484848484848 } @@ -3253,7 +3091,7 @@ async fn federation_formatting() { { "id": 951, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 4, "weightedRankingScore": 0.9848484848484848 } @@ -3261,7 +3099,7 @@ async fn federation_formatting() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -3269,7 +3107,7 @@ async fn federation_formatting() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 9, "weightedRankingScore": 0.9848484848484848 } @@ -3277,7 +3115,7 @@ async fn federation_formatting() { { "id": 654, "_federation": { - "indexUid": "nested", + "indexUid": "SHARED_NESTED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.7803030303030303 } @@ -3285,7 +3123,7 @@ async fn federation_formatting() { { "title": "Badman", "_federation": { - "indexUid": "score", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 8, "weightedRankingScore": 0.5 } @@ -3293,7 +3131,7 @@ async fn federation_formatting() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 6, "weightedRankingScore": 0.4166666666666667 } @@ -3310,17 +3148,17 @@ async fn federation_formatting() { { let (response, code) = server .multi_search(json!({"federation": {"offset": 12}, "queries": [ - {"indexUid" : "test", "q": "glass", "attributesToRetrieve": ["title"]}, - {"indexUid" : "test", "q": "captain", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "pésti", "attributesToRetrieve": ["id"]}, - {"indexUid" : "test", "q": "Escape", "attributesToRetrieve": ["title"]}, - {"indexUid": "nested", "q": "jean", "attributesToRetrieve": ["id"]}, - {"indexUid": "score", "q": "jean", "attributesToRetrieve": ["title"]}, - {"indexUid": "test", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "the bat", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "badman returns", "attributesToRetrieve": ["title"]}, - {"indexUid" : "score", "q": "batman", "attributesToRetrieve": ["title"]}, - {"indexUid": "score", "q": "batman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "captain", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "pésti", "attributesToRetrieve": ["id"]}, + {"indexUid" : index.uid, "q": "Escape", "attributesToRetrieve": ["title"]}, + {"indexUid" : nested_index.uid, "q": "jean", "attributesToRetrieve": ["id"]}, + {"indexUid" : score_index.uid, "q": "jean", "attributesToRetrieve": ["title"]}, + {"indexUid" : index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "the bat", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "badman returns", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman", "attributesToRetrieve": ["title"]}, + {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; snapshot!(code, @"200 OK"); @@ -3338,9 +3176,8 @@ async fn federation_formatting() { #[actix_rt::test] async fn federation_invalid_weight() { - let server = Server::new().await; - - let index = server.index("fruits"); + let server = Server::new_shared(); + let index = server.unique_index(); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -3355,8 +3192,8 @@ async fn federation_invalid_weight() { let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red", "filter": "BOOST = true", "showRankingScore": true, "federationOptions": {"weight": 3.0}}, - {"indexUid": "fruits", "q": "apple red", "showRankingScore": true, "federationOptions": {"weight": -12}}, + {"indexUid" : index.uid, "q": "apple red", "filter": "BOOST = true", "showRankingScore": true, "federationOptions": {"weight": 3.0}}, + {"indexUid": index.uid, "q": "apple red", "showRankingScore": true, "federationOptions": {"weight": -12}}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3372,9 +3209,9 @@ async fn federation_invalid_weight() { #[actix_rt::test] async fn federation_null_weight() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("fruits"); + let index = server.unique_index(); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -3389,12 +3226,12 @@ async fn federation_null_weight() { let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red", "filter": "BOOST = true", "showRankingScore": true, "federationOptions": {"weight": 3.0}}, - {"indexUid": "fruits", "q": "apple red", "showRankingScore": true, "federationOptions": {"weight": 0.0} }, + {"indexUid" : index.uid, "q": "apple red", "filter": "BOOST = true", "showRankingScore": true, "federationOptions": {"weight": 3.0}}, + {"indexUid": index.uid, "q": "apple red", "showRankingScore": true, "federationOptions": {"weight": 0.0} }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { @@ -3402,7 +3239,7 @@ async fn federation_null_weight() { "id": "red-delicious-boosted", "BOOST": true, "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 2.7281746031746033 }, @@ -3413,7 +3250,7 @@ async fn federation_null_weight() { "id": "green-apple-boosted", "BOOST": true, "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.318181818181818 }, @@ -3423,7 +3260,7 @@ async fn federation_null_weight() { "name": "Red apple gala", "id": "red-apple-gala", "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.0 }, @@ -3440,9 +3277,9 @@ async fn federation_null_weight() { #[actix_rt::test] async fn federation_federated_contains_pagination() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("fruits"); + let index = server.unique_index(); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -3451,8 +3288,8 @@ async fn federation_federated_contains_pagination() { // fail when a federated query contains "limit" let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "limit": 5}, + {"indexUid" : index.uid, "q": "apple red"}, + {"indexUid": index.uid, "q": "apple red", "limit": 5}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3467,8 +3304,8 @@ async fn federation_federated_contains_pagination() { // fail when a federated query contains "offset" let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "offset": 5}, + {"indexUid" : index.uid, "q": "apple red"}, + {"indexUid": index.uid, "q": "apple red", "offset": 5}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3483,8 +3320,8 @@ async fn federation_federated_contains_pagination() { // fail when a federated query contains "page" let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "page": 2}, + {"indexUid" : index.uid, "q": "apple red"}, + {"indexUid": index.uid, "q": "apple red", "page": 2}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3499,8 +3336,8 @@ async fn federation_federated_contains_pagination() { // fail when a federated query contains "hitsPerPage" let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "hitsPerPage": 5}, + {"indexUid" : index.uid, "q": "apple red"}, + {"indexUid": index.uid, "q": "apple red", "hitsPerPage": 5}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3516,9 +3353,9 @@ async fn federation_federated_contains_pagination() { #[actix_rt::test] async fn federation_federated_contains_facets() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("fruits"); + let index = server.unique_index(); let (value, _) = index .update_settings( @@ -3535,8 +3372,8 @@ async fn federation_federated_contains_facets() { // empty facets are actually OK let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "facets": []}, + {"indexUid" : index.uid, "q": "apple red"}, + {"indexUid": index.uid, "q": "apple red", "facets": []}, ]})) .await; snapshot!(code, @"200 OK"); @@ -3547,7 +3384,7 @@ async fn federation_federated_contains_facets() { "name": "Red apple gala", "id": "red-apple-gala", "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.953042328042328 } @@ -3557,7 +3394,7 @@ async fn federation_federated_contains_facets() { "id": "red-delicious-boosted", "BOOST": true, "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9093915343915344 } @@ -3567,7 +3404,7 @@ async fn federation_federated_contains_facets() { "id": "green-apple-boosted", "BOOST": true, "_federation": { - "indexUid": "fruits", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.4393939393939394 } @@ -3583,8 +3420,8 @@ async fn federation_federated_contains_facets() { // fails let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "facets": ["BOOSTED"]}, + {"indexUid": index.uid, "q": "apple red"}, + {"indexUid": index.uid, "q": "apple red", "facets": ["BOOSTED"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3600,48 +3437,49 @@ async fn federation_federated_contains_facets() { #[actix_rt::test] async fn federation_non_faceted_for_an_index() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("fruits"); + let fruits_index = server.unique_index(); - let (value, _) = index + let (value, _) = fruits_index .update_settings( json!({"searchableAttributes": ["name"], "filterableAttributes": ["BOOST", "id", "name"]}), ) .await; - index.wait_task(value.uid()).await.succeeded(); + fruits_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("fruits-no-name"); + let fruits_no_name_index = server.unique_index(); - let (value, _) = index + let (value, _) = fruits_no_name_index .update_settings( json!({"searchableAttributes": ["name"], "filterableAttributes": ["BOOST", "id"]}), ) .await; - index.wait_task(value.uid()).await.succeeded(); + fruits_no_name_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("fruits-no-facets"); + let fruits_no_facets_index = server.unique_index(); - let (value, _) = index.update_settings(json!({"searchableAttributes": ["name"]})).await; + let (value, _) = + fruits_no_facets_index.update_settings(json!({"searchableAttributes": ["name"]})).await; - index.wait_task(value.uid()).await.succeeded(); + fruits_no_facets_index.wait_task(value.uid()).await.succeeded(); let documents = FRUITS_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = fruits_no_facets_index.add_documents(documents, None).await; + fruits_no_facets_index.wait_task(value.uid()).await.succeeded(); // fails let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "fruits": ["BOOST", "id", "name"], - "fruits-no-name": ["BOOST", "id", "name"], + fruits_index.uid.clone(): ["BOOST", "id", "name"], + fruits_no_name_index.uid.clone(): ["BOOST", "id", "name"], } }, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits-no-name", "q": "apple red"}, + {"indexUid" : fruits_index.uid.clone(), "q": "apple red"}, + {"indexUid": fruits_no_name_index.uid.clone(), "q": "apple red"}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3658,12 +3496,12 @@ async fn federation_non_faceted_for_an_index() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "fruits": ["BOOST", "id", "name"], - "fruits-no-name": ["BOOST", "id", "name"], + fruits_index.uid.clone(): ["BOOST", "id", "name"], + fruits_no_name_index.uid.clone(): ["BOOST", "id", "name"], } }, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red"}, + {"indexUid" : fruits_index.uid.clone(), "q": "apple red"}, + {"indexUid": fruits_index.uid.clone(), "q": "apple red"}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3680,13 +3518,13 @@ async fn federation_non_faceted_for_an_index() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "fruits": ["BOOST", "id", "name"], - "fruits-no-name": ["BOOST", "id"], - "fruits-no-facets": ["BOOST", "id"], + fruits_index.uid.clone(): ["BOOST", "id", "name"], + fruits_no_name_index.uid.clone(): ["BOOST", "id"], + fruits_no_facets_index.uid.clone(): ["BOOST", "id"], } }, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red"}, + {"indexUid" : fruits_index.uid.clone(), "q": "apple red"}, + {"indexUid": fruits_index.uid.clone(), "q": "apple red"}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3704,11 +3542,11 @@ async fn federation_non_faceted_for_an_index() { .multi_search(json!({"federation": { "facetsByIndex": { "zorglub": ["BOOST", "id", "name"], - "fruits": ["BOOST", "id", "name"], + fruits_index.uid.clone(): ["BOOST", "id", "name"], } }, "queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red"}, + {"indexUid" : fruits_index.uid.clone(), "q": "apple red"}, + {"indexUid": fruits_index.uid.clone(), "q": "apple red"}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3724,9 +3562,9 @@ async fn federation_non_faceted_for_an_index() { #[actix_rt::test] async fn federation_non_federated_contains_federation_option() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("fruits"); + let index = server.unique_index(); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -3735,8 +3573,8 @@ async fn federation_non_federated_contains_federation_option() { // fail when a non-federated query contains "federationOptions" let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "fruits", "q": "apple red"}, - {"indexUid": "fruits", "q": "apple red", "federationOptions": {}}, + {"indexUid" : index.uid.clone(), "q": "apple red"}, + {"indexUid": index.uid.clone(), "q": "apple red", "federationOptions": {}}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -3752,9 +3590,9 @@ async fn federation_non_federated_contains_federation_option() { #[actix_rt::test] async fn federation_vector_single_index() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("vectors"); + let index = server.unique_index(); let (value, _) = index .update_settings(json!({"embedders": { @@ -3778,19 +3616,19 @@ async fn federation_vector_single_index() { // same embedder let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "vectors", "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}}, - {"indexUid": "vectors", "vector": [0.5, 0.5, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}}, + {"indexUid" : index.uid.clone(), "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}}, + {"indexUid": index.uid.clone(), "vector": [0.5, 0.5, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}}, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { "id": "B", "description": "the kitten scratched the beagle", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9870882034301758 } @@ -3799,7 +3637,7 @@ async fn federation_vector_single_index() { "id": "D", "description": "the little boy pets the puppy", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9728479385375975 } @@ -3808,7 +3646,7 @@ async fn federation_vector_single_index() { "id": "C", "description": "the dog had to stay alone today", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 } @@ -3817,7 +3655,7 @@ async fn federation_vector_single_index() { "id": "A", "description": "the dog barks at the cat", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9191691875457764 } @@ -3834,20 +3672,20 @@ async fn federation_vector_single_index() { // distinct embedder let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "vectors", "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}}, + {"indexUid" : index.uid.clone(), "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}}, // joyful and energetic first - {"indexUid": "vectors", "vector": [0.8, 0.6], "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"}}, + {"indexUid": index.uid.clone(), "vector": [0.8, 0.6], "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"}}, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { "id": "D", "description": "the little boy pets the puppy", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.979868710041046 } @@ -3856,7 +3694,7 @@ async fn federation_vector_single_index() { "id": "C", "description": "the dog had to stay alone today", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 } @@ -3865,7 +3703,7 @@ async fn federation_vector_single_index() { "id": "B", "description": "the kitten scratched the beagle", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 } @@ -3874,7 +3712,7 @@ async fn federation_vector_single_index() { "id": "A", "description": "the dog barks at the cat", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8432406187057495 } @@ -3891,21 +3729,21 @@ async fn federation_vector_single_index() { // hybrid search, distinct embedder let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "vectors", "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}, "showRankingScore": true}, + {"indexUid" : index.uid, "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}, "showRankingScore": true}, // joyful and energetic first - {"indexUid": "vectors", "vector": [0.8, 0.6], "q": "beagle", "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"},"showRankingScore": true}, - {"indexUid": "vectors", "q": "dog", "showRankingScore": true}, + {"indexUid": index.uid, "vector": [0.8, 0.6], "q": "beagle", "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"},"showRankingScore": true}, + {"indexUid": index.uid, "q": "dog", "showRankingScore": true}, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { "id": "D", "description": "the little boy pets the puppy", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.979868710041046 }, @@ -3915,7 +3753,7 @@ async fn federation_vector_single_index() { "id": "C", "description": "the dog had to stay alone today", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 }, @@ -3925,7 +3763,7 @@ async fn federation_vector_single_index() { "id": "A", "description": "the dog barks at the cat", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9242424242424242 }, @@ -3935,7 +3773,7 @@ async fn federation_vector_single_index() { "id": "B", "description": "the kitten scratched the beagle", "_federation": { - "indexUid": "vectors", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 }, @@ -3953,11 +3791,11 @@ async fn federation_vector_single_index() { #[actix_rt::test] async fn federation_vector_two_indexes() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("vectors-animal"); + let vectors_animal_index = server.unique_index(); - let (value, _) = index + let (value, _) = vectors_animal_index .update_settings(json!({"embedders": { "animal": { "source": "userProvided", @@ -3965,16 +3803,16 @@ async fn federation_vector_two_indexes() { }, }})) .await; - index.wait_task(value.uid()).await.succeeded(); + vectors_animal_index.wait_task(value.uid()).await.succeeded(); let documents = VECTOR_DOCUMENTS.clone(); - let (value, code) = index.add_documents(documents, None).await; + let (value, code) = vectors_animal_index.add_documents(documents, None).await; snapshot!(code, @"202 Accepted"); - index.wait_task(value.uid()).await.succeeded(); + vectors_animal_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("vectors-sentiment"); + let vectors_sentiment_index = server.unique_index(); - let (value, _) = index + let (value, _) = vectors_sentiment_index .update_settings(json!({"embedders": { "sentiment": { "source": "userProvided", @@ -3982,23 +3820,23 @@ async fn federation_vector_two_indexes() { } }})) .await; - index.wait_task(value.uid()).await.succeeded(); + vectors_sentiment_index.wait_task(value.uid()).await.succeeded(); let documents = VECTOR_DOCUMENTS.clone(); - let (value, code) = index.add_documents(documents, None).await; + let (value, code) = vectors_sentiment_index.add_documents(documents, None).await; snapshot!(code, @"202 Accepted"); - index.wait_task(value.uid()).await.succeeded(); + vectors_sentiment_index.wait_task(value.uid()).await.succeeded(); let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "vectors-animal", "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}, "retrieveVectors": true}, + {"indexUid" : vectors_animal_index.uid, "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}, "retrieveVectors": true}, // joyful and energetic first - {"indexUid": "vectors-sentiment", "vector": [0.8, 0.6], "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"}, "retrieveVectors": true}, - {"indexUid": "vectors-sentiment", "q": "dog", "retrieveVectors": true}, + {"indexUid": vectors_sentiment_index.uid, "vector": [0.8, 0.6], "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"}, "retrieveVectors": true}, + {"indexUid": vectors_sentiment_index.uid, "q": "dog", "retrieveVectors": true}, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -4021,7 +3859,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.979868710041046 } @@ -4046,7 +3884,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9728479385375975 } @@ -4071,7 +3909,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 } @@ -4096,7 +3934,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9242424242424242 } @@ -4121,7 +3959,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9242424242424242 } @@ -4146,7 +3984,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 } @@ -4171,7 +4009,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8432406187057495 } @@ -4196,7 +4034,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.6690993905067444 } @@ -4213,12 +4051,12 @@ async fn federation_vector_two_indexes() { // hybrid search, distinct embedder let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "vectors-animal", "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}, "showRankingScore": true, "retrieveVectors": true}, - {"indexUid": "vectors-sentiment", "vector": [-1, 0.6], "q": "beagle", "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"}, "showRankingScore": true, "retrieveVectors": true,}, + {"indexUid" : vectors_animal_index.uid, "vector": [1.0, 0.0, 0.5], "hybrid": {"semanticRatio": 1.0, "embedder": "animal"}, "showRankingScore": true, "retrieveVectors": true}, + {"indexUid": vectors_sentiment_index.uid, "vector": [-1, 0.6], "q": "beagle", "hybrid": {"semanticRatio": 1.0, "embedder": "sentiment"}, "showRankingScore": true, "retrieveVectors": true,}, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -4241,7 +4079,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9728479385375975 }, @@ -4267,7 +4105,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 }, @@ -4293,7 +4131,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9522157907485962 }, @@ -4319,7 +4157,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8719604015350342 }, @@ -4345,7 +4183,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 }, @@ -4371,7 +4209,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-animal", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8432406187057495 }, @@ -4397,7 +4235,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8297949433326721 }, @@ -4423,7 +4261,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.18887794017791748 }, @@ -4441,15 +4279,15 @@ async fn federation_vector_two_indexes() { #[actix_rt::test] async fn federation_facets_different_indexes_same_facet() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("movies"); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "filterableAttributes": ["title", "color"], @@ -4463,15 +4301,15 @@ async fn federation_facets_different_indexes_same_facet() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["title"], "filterableAttributes": ["title"], @@ -4485,15 +4323,15 @@ async fn federation_facets_different_indexes_same_facet() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman-2"); + let batman_2_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_2_index.add_documents(documents, None).await; + batman_2_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_2_index .update_settings(json!({ "sortableAttributes": ["title"], "filterableAttributes": ["title"], @@ -4507,30 +4345,30 @@ async fn federation_facets_different_indexes_same_facet() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_2_index.wait_task(value.uid()).await.succeeded(); // return titles ordered accross indexes let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "batman-2": ["title"], + movies_index.uid.clone(): ["title", "color"], + batman_index.uid.clone(): ["title"], + batman_2_index.uid.clone(): ["title"], } }, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_2_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4538,7 +4376,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4546,7 +4384,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4554,7 +4392,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4562,7 +4400,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4570,7 +4408,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4578,7 +4416,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4586,7 +4424,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4594,7 +4432,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4602,7 +4440,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4610,7 +4448,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4618,7 +4456,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Escape Room", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4626,7 +4464,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Gläss", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4634,7 +4472,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4642,7 +4480,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Shazam!", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4702,25 +4540,25 @@ async fn federation_facets_different_indexes_same_facet() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "movies": ["title"], - "batman": ["title"], - "batman-2": ["title"] + movies_index.uid.clone(): ["title"], + batman_index.uid.clone(): ["title"], + batman_2_index.uid.clone(): ["title"] }, "mergeFacets": {} }, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_2_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4728,7 +4566,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4736,7 +4574,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4744,7 +4582,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4752,7 +4590,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4760,7 +4598,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4768,7 +4606,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4776,7 +4614,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4784,7 +4622,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4792,7 +4630,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4800,7 +4638,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4808,7 +4646,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Escape Room", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4816,7 +4654,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Gläss", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4824,7 +4662,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4832,7 +4670,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Shazam!", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4864,25 +4702,25 @@ async fn federation_facets_different_indexes_same_facet() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "movies": [], - "batman": ["title"], - "batman-2": ["title"] + movies_index.uid.clone(): [], + batman_index.uid.clone(): ["title"], + batman_2_index.uid.clone(): ["title"] } }, "queries": [ - {"indexUid" : "batman", "q": "badman returns", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman-2", "q": "badman returns", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "movies", "q": "captain", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman", "q": "the bat", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "badman returns", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_2_index.uid.clone(), "q": "badman returns", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies_index.uid.clone(), "q": "captain", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "the bat", "sort": ["title:desc"], "attributesToRetrieve": ["title"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Captain Marvel", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9848484848484848 } @@ -4890,7 +4728,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 3, "weightedRankingScore": 0.9528218694885362 } @@ -4898,7 +4736,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.7028218694885362 } @@ -4906,7 +4744,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 3, "weightedRankingScore": 0.9528218694885362 } @@ -4914,7 +4752,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.7028218694885362 } @@ -4922,7 +4760,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8317901234567902 } @@ -4930,7 +4768,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8317901234567902 } @@ -4938,7 +4776,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.23106060606060605 } @@ -4946,7 +4784,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.23106060606060605 } @@ -4954,7 +4792,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.5 } @@ -4962,7 +4800,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.5 } @@ -5008,15 +4846,15 @@ async fn federation_facets_different_indexes_same_facet() { #[actix_rt::test] async fn federation_facets_same_indexes() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("doggos"); + let doggos_index = server.unique_index(); let documents = NESTED_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = doggos_index.add_documents(documents, None).await; + doggos_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = doggos_index .update_settings(json!({ "filterableAttributes": ["father", "mother", "doggos.age"], "rankingRules": [ @@ -5029,15 +4867,15 @@ async fn federation_facets_same_indexes() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + doggos_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("doggos-2"); + let doggos2_index = server.unique_index(); let documents = NESTED_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = doggos2_index.add_documents(documents, None).await; + doggos2_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = doggos2_index .update_settings(json!({ "filterableAttributes": ["father", "mother", "doggos.age"], "rankingRules": [ @@ -5050,26 +4888,26 @@ async fn federation_facets_same_indexes() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + doggos2_index.wait_task(value.uid()).await.succeeded(); let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "doggos": ["father", "mother", "doggos.age"] + doggos_index.uid.clone(): ["father", "mother", "doggos.age"] } }, "queries": [ - {"indexUid" : "doggos", "q": "je", "attributesToRetrieve": ["id"] }, - {"indexUid" : "doggos", "q": "michel", "attributesToRetrieve": ["id"] }, + {"indexUid" : doggos_index.uid.clone(), "q": "je", "attributesToRetrieve": ["id"] }, + {"indexUid" : doggos_index.uid.clone(), "q": "michel", "attributesToRetrieve": ["id"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "id": 852, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5077,7 +4915,7 @@ async fn federation_facets_same_indexes() { { "id": 951, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5085,7 +4923,7 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5128,22 +4966,22 @@ async fn federation_facets_same_indexes() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "doggos": ["father", "mother", "doggos.age"], - "doggos-2": ["father", "mother", "doggos.age"] + doggos_index.uid.clone(): ["father", "mother", "doggos.age"], + doggos2_index.uid.clone(): ["father", "mother", "doggos.age"] } }, "queries": [ - {"indexUid" : "doggos", "q": "je", "attributesToRetrieve": ["id"] }, - {"indexUid" : "doggos-2", "q": "michel", "attributesToRetrieve": ["id"] }, + {"indexUid" : doggos_index.uid.clone(), "q": "je", "attributesToRetrieve": ["id"] }, + {"indexUid" : doggos2_index.uid.clone(), "q": "michel", "attributesToRetrieve": ["id"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "id": 852, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5151,7 +4989,7 @@ async fn federation_facets_same_indexes() { { "id": 951, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5159,7 +4997,7 @@ async fn federation_facets_same_indexes() { { "id": 852, "_federation": { - "indexUid": "doggos-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5167,7 +5005,7 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "doggos-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5230,23 +5068,23 @@ async fn federation_facets_same_indexes() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "doggos": ["father", "mother", "doggos.age"], - "doggos-2": ["father", "mother", "doggos.age"] + doggos_index.uid.clone(): ["father", "mother", "doggos.age"], + doggos2_index.uid.clone(): ["father", "mother", "doggos.age"] }, "mergeFacets": {}, }, "queries": [ - {"indexUid" : "doggos", "q": "je", "attributesToRetrieve": ["id"] }, - {"indexUid" : "doggos-2", "q": "michel", "attributesToRetrieve": ["id"] }, + {"indexUid" : doggos_index.uid.clone(), "q": "je", "attributesToRetrieve": ["id"] }, + {"indexUid" : doggos2_index.uid.clone(), "q": "michel", "attributesToRetrieve": ["id"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "id": 852, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5254,7 +5092,7 @@ async fn federation_facets_same_indexes() { { "id": 951, "_federation": { - "indexUid": "doggos", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5262,7 +5100,7 @@ async fn federation_facets_same_indexes() { { "id": 852, "_federation": { - "indexUid": "doggos-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5270,7 +5108,7 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "doggos-2", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5309,15 +5147,15 @@ async fn federation_facets_same_indexes() { #[actix_rt::test] async fn federation_inconsistent_merge_order() { - let server = Server::new().await; + let server = Server::new_shared(); - let index = server.index("movies"); + let movies_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies_index .update_settings(json!({ "sortableAttributes": ["title"], "filterableAttributes": ["title", "color"], @@ -5331,15 +5169,15 @@ async fn federation_inconsistent_merge_order() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("movies-2"); + let movies2_index = server.unique_index(); let documents = DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = movies2_index.add_documents(documents, None).await; + movies2_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = movies2_index .update_settings(json!({ "sortableAttributes": ["title"], "filterableAttributes": ["title", "color"], @@ -5356,15 +5194,15 @@ async fn federation_inconsistent_merge_order() { } })) .await; - index.wait_task(value.uid()).await.succeeded(); + movies2_index.wait_task(value.uid()).await.succeeded(); - let index = server.index("batman"); + let batman_index = server.unique_index(); let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = index.add_documents(documents, None).await; - index.wait_task(value.uid()).await.succeeded(); + let (value, _) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(value.uid()).await.succeeded(); - let (value, _) = index + let (value, _) = batman_index .update_settings(json!({ "sortableAttributes": ["title"], "filterableAttributes": ["title"], @@ -5378,30 +5216,30 @@ async fn federation_inconsistent_merge_order() { ] })) .await; - index.wait_task(value.uid()).await.succeeded(); + batman_index.wait_task(value.uid()).await.succeeded(); // without merging, it works let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "movies-2": ["title", "color"], + movies_index.uid.clone(): ["title", "color"], + batman_index.uid.clone(): ["title"], + movies2_index.uid.clone(): ["title", "color"], } }, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "movies-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies2_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5409,7 +5247,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5417,7 +5255,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5425,7 +5263,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5433,7 +5271,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5441,7 +5279,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5449,7 +5287,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5457,7 +5295,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5465,7 +5303,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5473,7 +5311,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5481,7 +5319,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5489,7 +5327,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5497,7 +5335,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5505,7 +5343,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5513,7 +5351,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5580,21 +5418,21 @@ async fn federation_inconsistent_merge_order() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "movies-2": ["title", "color"], + movies_index.uid.clone(): ["title", "color"], + batman_index.uid.clone(): ["title"], + movies2_index.uid.clone(): ["title", "color"], }, "mergeFacets": {} }, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "movies-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies2_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { - "message": "Inside `.federation.facetsByIndex.movies-2`: Inconsistent order for values in facet `color`: index `movies` orders alphabetically, but index `movies-2` orders by count.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `movies-2` used in `.queries[2]`", + "message": "Inside `.federation.facetsByIndex.movies-2`: Inconsistent order for values in facet `color`: index `[uuid]` orders alphabetically, but index `[uuid]` orders by count.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `[uuid]` used in `.queries[2]`", "code": "invalid_multi_search_facet_order", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facet_order" @@ -5605,27 +5443,27 @@ async fn federation_inconsistent_merge_order() { let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "movies-2": ["title"], + movies_index.uid.clone(): ["title", "color"], + batman_index.uid.clone(): ["title"], + movies2_index.uid.clone(): ["title"], }, "mergeFacets": { "maxValuesPerFacet": 3, } }, "queries": [ - {"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, - {"indexUid" : "movies-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : batman_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, + {"indexUid" : movies2_index.uid.clone(), "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] }, ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5633,7 +5471,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5641,7 +5479,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5649,7 +5487,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5657,7 +5495,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman", + "indexUid": "[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5665,7 +5503,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5673,7 +5511,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5681,7 +5519,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5689,7 +5527,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5697,7 +5535,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5705,7 +5543,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5713,7 +5551,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5721,7 +5559,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5729,7 +5567,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "movies", + "indexUid": "[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5737,7 +5575,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "movies-2", + "indexUid": "[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } From 34d8a54c4b93e8b424030c1b5156b8fef8cba0f6 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Tue, 10 Jun 2025 14:48:59 +0300 Subject: [PATCH 02/17] Fix typos in comments and update assertions Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 8eea27792..d10836177 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -164,7 +164,7 @@ async fn federation_single_search_single_index() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -1104,7 +1104,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { .await; index.wait_task(value.uid()).await.succeeded(); - // two identical placeholder search should have all results from first query + // two identical placeholder searches should have all results from the first query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, @@ -1317,7 +1317,7 @@ async fn federation_sort_same_indexes_same_criterion_opposite_direction() { .await; index.wait_task(value.uid()).await.succeeded(); - // two identical placeholder search should have all results from first query + // two identical placeholder searches should have all results from the first query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, @@ -1376,7 +1376,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { .await; index.wait_task(value.uid()).await.succeeded(); - // return mothers and fathers ordered accross fields. + // return mothers and fathers ordered across fields. let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, @@ -1590,7 +1590,7 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { .await; index.wait_task(value.uid()).await.succeeded(); - // two identical placeholder search should have all results from first query + // two identical placeholder searches should have all results from the first query let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : index.uid, "q": "", "sort": ["mother:asc"], "showRankingScore": true }, @@ -1670,7 +1670,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { .await; batman_index.wait_task(value.uid()).await.succeeded(); - // return titles ordered accross indexes + // return titles ordered across indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, @@ -1940,7 +1940,7 @@ async fn federation_sort_different_ranking_rules() { .await; batman_index.wait_task(value.uid()).await.succeeded(); - // return titles ordered accross indexes + // return titles ordered across indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, @@ -2226,7 +2226,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() .await; batman_index.wait_task(value.uid()).await.succeeded(); - // return titles ordered accross indexes + // return titles ordered across indexes let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : movies_index.uid, "q": "", "sort": ["title:asc"], "showRankingScore": true }, @@ -3377,7 +3377,7 @@ async fn federation_federated_contains_facets() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" { "hits": [ { @@ -4347,7 +4347,7 @@ async fn federation_facets_different_indexes_same_facet() { .await; batman_2_index.wait_task(value.uid()).await.succeeded(); - // return titles ordered accross indexes + // return titles ordered across indexes let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { From 1824fbd1b513c1b00f68f45cebdcd2c6f4252fbe Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Tue, 10 Jun 2025 14:49:18 +0300 Subject: [PATCH 03/17] Introduce Index::unique_index_with_prefix(&str) It could be used when we want to see the index name in the assertions, e.g. `movies-[uuid]` Signed-off-by: Martin Tzvetanov Grigorov --- crates/meili-snap/src/lib.rs | 16 +++--------- crates/meilisearch/tests/common/server.rs | 10 ++++++++ crates/meilisearch/tests/search/multi/mod.rs | 26 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/meili-snap/src/lib.rs b/crates/meili-snap/src/lib.rs index e9fa94159..7ef72ed06 100644 --- a/crates/meili-snap/src/lib.rs +++ b/crates/meili-snap/src/lib.rs @@ -43,20 +43,10 @@ pub fn default_snapshot_settings_for_test<'a>( } } - fn uuid_in_index_uid_redaction(content: Content, _content_path: ContentPath) -> Content { - match &content { - Content::String(s) => match uuid::Uuid::parse_str(s) { - Ok(_) => Content::String("[uuid]".to_owned()), - Err(_) => content, - }, - _ => content, - } - } - settings.add_dynamic_redaction(".message", uuid_in_message_redaction); - settings.add_dynamic_redaction(".error.message", uuid_in_message_redaction); - settings.add_dynamic_redaction(".indexUid", uuid_in_index_uid_redaction); - settings.add_dynamic_redaction(".**.indexUid", uuid_in_index_uid_redaction); + settings.add_dynamic_redaction(".**.message", uuid_in_message_redaction); + settings.add_dynamic_redaction(".indexUid", uuid_in_message_redaction); + settings.add_dynamic_redaction(".**.indexUid", uuid_in_message_redaction); let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name); let test_name = test_name.rsplit("::").next().unwrap().to_owned(); diff --git a/crates/meilisearch/tests/common/server.rs b/crates/meilisearch/tests/common/server.rs index 431972983..fecdc5f16 100644 --- a/crates/meilisearch/tests/common/server.rs +++ b/crates/meilisearch/tests/common/server.rs @@ -347,6 +347,16 @@ impl Server { } } + pub fn unique_index_with_prefix(&self, prefix: &str) -> Index<'_> { + let uuid = Uuid::new_v4(); + Index { + uid: format!("{prefix}-{}", uuid.to_string()), + service: &self.service, + encoder: Encoder::Plain, + marker: PhantomData, + } + } + pub fn unique_index_with_encoder(&self, encoder: Encoder) -> Index<'_> { let uuid = Uuid::new_v4(); Index { uid: uuid.to_string(), service: &self.service, encoder, marker: PhantomData } diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index d10836177..3914e7c9d 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1628,7 +1628,7 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { #[actix_rt::test] async fn federation_sort_different_indexes_same_criterion_same_direction() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -1649,7 +1649,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -1678,14 +1678,14 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" { "hits": [ { "title": "Badman", "id": "E", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1695,7 +1695,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1705,7 +1705,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1715,7 +1715,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1725,7 +1725,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1739,7 +1739,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1753,7 +1753,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1767,7 +1767,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1781,7 +1781,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -1795,7 +1795,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, From 6a683975bfb91cb3973c950fb20e086d58f2344e Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Tue, 10 Jun 2025 16:58:48 +0300 Subject: [PATCH 04/17] More fixes of the tests Signed-off-by: Martin Tzvetanov Grigorov --- crates/meili-snap/src/lib.rs | 20 + crates/meilisearch/tests/common/server.rs | 2 +- crates/meilisearch/tests/search/multi/mod.rs | 625 +++++++++---------- 3 files changed, 333 insertions(+), 314 deletions(-) diff --git a/crates/meili-snap/src/lib.rs b/crates/meili-snap/src/lib.rs index 7ef72ed06..fcd17879e 100644 --- a/crates/meili-snap/src/lib.rs +++ b/crates/meili-snap/src/lib.rs @@ -43,10 +43,30 @@ pub fn default_snapshot_settings_for_test<'a>( } } + fn uuid_in_json_key_redaction(content: Content, _content_path: ContentPath) -> Content { + match content { + Content::Map(map) => { + let new_map = map.iter() + .map(|(key, value)| { + match key { + Content::String(s) => { + let uuid_replaced = UUID_IN_MESSAGE_RE.replace_all(s, "[uuid]"); + (Content::String(uuid_replaced.to_string()), value.clone()) + } + _ => (key.clone(), value.clone()), + } + }).collect(); + Content::Map(new_map) + } + _ => content, + } + } + settings.add_dynamic_redaction(".message", uuid_in_message_redaction); settings.add_dynamic_redaction(".**.message", uuid_in_message_redaction); settings.add_dynamic_redaction(".indexUid", uuid_in_message_redaction); settings.add_dynamic_redaction(".**.indexUid", uuid_in_message_redaction); + settings.add_dynamic_redaction(".facetsByIndex", uuid_in_json_key_redaction); let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name); let test_name = test_name.rsplit("::").next().unwrap().to_owned(); diff --git a/crates/meilisearch/tests/common/server.rs b/crates/meilisearch/tests/common/server.rs index fecdc5f16..1f5688a02 100644 --- a/crates/meilisearch/tests/common/server.rs +++ b/crates/meilisearch/tests/common/server.rs @@ -350,7 +350,7 @@ impl Server { pub fn unique_index_with_prefix(&self, prefix: &str) -> Index<'_> { let uuid = Uuid::new_v4(); Index { - uid: format!("{prefix}-{}", uuid.to_string()), + uid: format!("{prefix}-{}", uuid), service: &self.service, encoder: Encoder::Plain, marker: PhantomData, diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 3914e7c9d..d75a09364 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -29,10 +29,10 @@ async fn federation_empty_list() { let (response, code) = server.multi_search(json!({"federation": {}, "queries": []})).await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, {".processingTimeMs" => "[time]"}), @r###" + snapshot!(response, @r###" { "hits": [], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 0 @@ -100,7 +100,7 @@ async fn simple_search_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response["results"], { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" [ { "indexUid": "SHARED_DOCUMENTS", @@ -115,7 +115,7 @@ async fn simple_search_single_index() { } ], "query": "glass", - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 1 @@ -133,7 +133,7 @@ async fn simple_search_single_index() { } ], "query": "captain", - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 1 @@ -153,7 +153,7 @@ async fn federation_single_search_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -170,7 +170,7 @@ async fn federation_single_search_single_index() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 1 @@ -192,7 +192,7 @@ async fn federation_multiple_search_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -241,7 +241,7 @@ async fn federation_multiple_search_single_index() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 5 @@ -261,7 +261,7 @@ async fn federation_two_search_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -291,7 +291,7 @@ async fn federation_two_search_single_index() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 2 @@ -309,7 +309,7 @@ async fn simple_search_missing_index_uid() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, @r###" + snapshot!(response, @r###" { "message": "Missing field `indexUid` inside `.queries[0]`", "code": "missing_index_uid", @@ -329,7 +329,7 @@ async fn federation_simple_search_missing_index_uid() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, @r###" + snapshot!(response, @r###" { "message": "Missing field `indexUid` inside `.queries[0]`", "code": "missing_index_uid", @@ -349,7 +349,7 @@ async fn simple_search_illegal_index_uid() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, @r###" + snapshot!(response, @r###" { "message": "Invalid value at `.queries[0].indexUid`: `hé` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_), and can not be more than 512 bytes.", "code": "invalid_index_uid", @@ -369,7 +369,7 @@ async fn federation_search_illegal_index_uid() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, @r###" + snapshot!(response, @r###" { "message": "Invalid value at `.queries[0].indexUid`: `hé` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_), and can not be more than 512 bytes.", "code": "invalid_index_uid", @@ -393,7 +393,7 @@ async fn simple_search_two_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response["results"], { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" [ { "indexUid": "SHARED_DOCUMENTS", @@ -408,7 +408,7 @@ async fn simple_search_two_indexes() { } ], "query": "glass", - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 1 @@ -449,7 +449,7 @@ async fn simple_search_two_indexes() { } ], "query": "pésti", - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 2 @@ -471,7 +471,7 @@ async fn federation_two_search_two_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -482,7 +482,7 @@ async fn federation_two_search_two_indexes() { "red" ], "_federation": { - "indexUid": "SHARED_NESTED_DOCUMENTS", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -529,7 +529,7 @@ async fn federation_two_search_two_indexes() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3 @@ -562,7 +562,7 @@ async fn federation_multiple_search_multiple_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -728,7 +728,7 @@ async fn federation_multiple_search_multiple_indexes() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 12 @@ -832,15 +832,14 @@ async fn search_one_query_error() { let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : index.uid, "q": "glass", "facets": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "facets": ["color"]}, {"indexUid": nested_index.uid, "q": "pésti"}, ]})) .await; - dbg!(&response); snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Invalid facet distribution: Attribute `title` is not filterable. This index does not have configured filterable attributes.", + "message": "Inside `.queries[0]`: Invalid facet distribution: Attribute `color` is not filterable. Available filterable attributes patterns are: `id, title`.", "code": "invalid_search_facets", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_facets" @@ -864,7 +863,7 @@ async fn federation_one_query_error() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `title` is not filterable. This index does not have configured filterable attributes.\n1:6 title = toto", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `title` is not filterable. Available filterable attribute patterns are: `cattos`, `doggos`, `father`.\n1:6 title = toto", "code": "invalid_search_filter", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_filter" @@ -884,6 +883,7 @@ async fn federation_one_query_sort_error() { {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, ]})) .await; + dbg!(&response); snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { @@ -903,15 +903,14 @@ async fn search_multiple_query_errors() { let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : index.uid, "q": "glass", "facets": ["title"]}, + {"indexUid" : index.uid, "q": "glass", "facets": ["color"]}, {"indexUid": nested_index.uid, "q": "pésti", "facets": ["doggos"]}, ]})) .await; - dbg!(&response); snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Invalid facet distribution: Attribute `title` is not filterable. This index does not have configured filterable attributes.", + "message": "Inside `.queries[0]`: Invalid facet distribution: Attribute `color` is not filterable. Available filterable attributes patterns are: `id, title`.", "code": "invalid_search_facets", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_facets" @@ -927,14 +926,14 @@ async fn federation_multiple_query_errors() { let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : index.uid, "q": "glass", "filter": ["title = toto"]}, - {"indexUid": nested_index.uid, "q": "pésti", "filter": ["doggos IN [intel, kefir]"]}, + {"indexUid" : index.uid, "q": "glass", "filter": ["color = toto"]}, + {"indexUid": nested_index.uid, "q": "pésti", "filter": ["mother IN [intel, kefir]"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Index `test`: Attribute `title` is not filterable. This index does not have configured filterable attributes.\n1:6 title = toto", + "message": "Inside `.queries[0]`: Index `SHARED_DOCUMENTS`: Attribute `color` is not filterable. Available filterable attribute patterns are: `id`, `title`.\n1:6 color = toto", "code": "invalid_search_filter", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_filter" @@ -950,14 +949,14 @@ async fn federation_multiple_query_sort_errors() { let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : index.uid, "q": "glass", "sort": ["title:desc"]}, + {"indexUid" : index.uid, "q": "glass", "sort": ["color:desc"]}, {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Index `SHARED_DOCUMENTS`: Attribute `title` is not sortable. This index does not have configured sortable attributes.", + "message": "Inside `.queries[0]`: Index `SHARED_DOCUMENTS`: Attribute `color` is not sortable. Available sortable attributes are: `id, title`.", "code": "invalid_search_sort", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_sort" @@ -974,14 +973,14 @@ async fn federation_multiple_query_errors_interleaved() { let (response, code) = server .multi_search(json!({"queries": [ {"indexUid" : index.uid, "q": "glass"}, - {"indexUid": nested_index.uid, "q": "pésti", "filter": ["doggos IN [intel, kefir]"]}, + {"indexUid": nested_index.uid, "q": "pésti", "filter": ["mother IN [intel, kefir]"]}, {"indexUid" : index.uid, "q": "glass", "filter": ["title = toto"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `doggos` is not filterable. This index does not have configured filterable attributes.\n1:7 doggos IN [intel, kefir]", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `mother` is not filterable. Available filterable attribute patterns are: `cattos`, `doggos`, `father`.\n1:7 mother IN [intel, kefir]", "code": "invalid_search_filter", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_filter" @@ -998,14 +997,14 @@ async fn federation_multiple_query_sort_errors_interleaved() { let (response, code) = server .multi_search(json!({"queries": [ {"indexUid" : index.uid, "q": "glass"}, - {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, + {"indexUid": nested_index.uid, "q": "pésti", "sort": ["mother:desc"]}, {"indexUid" : index.uid, "q": "glass", "sort": ["title:desc"]}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `doggos` is not sortable. This index does not have configured sortable attributes.", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `mother` is not sortable. Available sortable attributes are: `doggos`.", "code": "invalid_search_sort", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_sort" @@ -1036,7 +1035,7 @@ async fn federation_filter() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(response, @r###" { "hits": [ { @@ -1072,7 +1071,7 @@ async fn federation_filter() { "_rankingScore": 0.953042328042328 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3 @@ -1112,7 +1111,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -1198,7 +1197,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "_rankingScore": 1.0 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4 @@ -1213,7 +1212,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -1285,7 +1284,7 @@ async fn federation_sort_same_indexes_same_criterion_same_direction() { "_rankingScore": 0.9848484848484848 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3 @@ -1325,7 +1324,7 @@ async fn federation_sort_same_indexes_same_criterion_opposite_direction() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `mother`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", @@ -1342,7 +1341,7 @@ async fn federation_sort_same_indexes_same_criterion_opposite_direction() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `mother`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", @@ -1384,7 +1383,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -1470,7 +1469,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "_rankingScore": 1.0 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4 @@ -1486,7 +1485,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -1558,7 +1557,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { "_rankingScore": 0.9991181657848324 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3 @@ -1569,7 +1568,7 @@ async fn federation_sort_same_indexes_different_criterion_same_direction() { #[actix_rt::test] async fn federation_sort_same_indexes_different_criterion_opposite_direction() { let server = Server::new_shared(); - let index = server.unique_index(); + let index = server.unique_index_with_prefix("nested"); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -1598,9 +1597,9 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested-[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested-[uuid].rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -1615,9 +1614,9 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested.rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested.rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested-[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested.rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -1678,7 +1677,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -1802,7 +1801,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "_rankingScore": 1.0 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 10 @@ -1818,7 +1817,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -1829,7 +1828,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 }, @@ -1839,7 +1838,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -1849,7 +1848,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -1859,7 +1858,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8317901234567902 }, @@ -1869,7 +1868,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.23106060606060605 }, @@ -1879,14 +1878,14 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { "title": "Badman", "id": "E", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.5 }, "_rankingScore": 0.5 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 6 @@ -1898,7 +1897,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { async fn federation_sort_different_ranking_rules() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -1919,7 +1918,7 @@ async fn federation_sort_different_ranking_rules() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -1948,14 +1947,14 @@ async fn federation_sort_different_ranking_rules() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Badman", "id": "E", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1965,7 +1964,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1975,7 +1974,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1985,7 +1984,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1995,7 +1994,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2009,7 +2008,7 @@ async fn federation_sort_different_ranking_rules() { "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2023,7 +2022,7 @@ async fn federation_sort_different_ranking_rules() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2037,7 +2036,7 @@ async fn federation_sort_different_ranking_rules() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2051,7 +2050,7 @@ async fn federation_sort_different_ranking_rules() { "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2065,14 +2064,14 @@ async fn federation_sort_different_ranking_rules() { "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, "_rankingScore": 1.0 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 10 @@ -2088,9 +2087,9 @@ async fn federation_sort_different_ranking_rules() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `[uuid].rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `batman-[uuid].rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2102,7 +2101,7 @@ async fn federation_sort_different_ranking_rules() { async fn federation_sort_different_indexes_same_criterion_opposite_direction() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -2123,7 +2122,7 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -2152,9 +2151,9 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n 2. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n 2. `queries[0].sort[0]`, `batman-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2170,7 +2169,7 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", @@ -2184,7 +2183,7 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { async fn federation_sort_different_indexes_different_criterion_same_direction() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -2205,7 +2204,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -2234,14 +2233,14 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2251,7 +2250,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2261,7 +2260,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2275,7 +2274,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2285,7 +2284,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman", "id": "D", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2295,7 +2294,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Badman", "id": "E", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2309,7 +2308,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2323,7 +2322,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2337,7 +2336,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "red" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, @@ -2351,14 +2350,14 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 }, "_rankingScore": 1.0 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 10 @@ -2374,14 +2373,14 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Badman", "id": "E", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.5 }, @@ -2391,7 +2390,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman", "id": "D", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.23106060606060605 }, @@ -2405,7 +2404,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "blue" ], "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9848484848484848 }, @@ -2415,7 +2414,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8317901234567902 }, @@ -2425,7 +2424,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, @@ -2435,14 +2434,14 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9528218694885362 }, "_rankingScore": 0.9528218694885362 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 6 @@ -2454,7 +2453,7 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() async fn federation_sort_different_indexes_different_criterion_opposite_direction() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -2475,7 +2474,7 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -2504,9 +2503,9 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[0].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[0].sort[0]`, `batman-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2522,7 +2521,7 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", @@ -2535,7 +2534,7 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio #[actix_rt::test] async fn federation_limit_offset() { let server = Server::new_shared(); - let index = server.unique_index(); + let index = shared_index_with_documents().await; let nested_index = shared_index_with_nested_documents().await; let score_index = shared_index_with_score_documents().await; @@ -2555,8 +2554,9 @@ async fn federation_limit_offset() { {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; + dbg!(&response); snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -2656,7 +2656,7 @@ async fn federation_limit_offset() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 12 @@ -2681,7 +2681,7 @@ async fn federation_limit_offset() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -2693,7 +2693,7 @@ async fn federation_limit_offset() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 1, "offset": 0, "estimatedTotalHits": 12 @@ -2718,7 +2718,7 @@ async fn federation_limit_offset() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -2802,7 +2802,7 @@ async fn federation_limit_offset() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 2, "estimatedTotalHits": 12 @@ -2827,10 +2827,10 @@ async fn federation_limit_offset() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 12, "estimatedTotalHits": 12 @@ -2842,10 +2842,9 @@ async fn federation_limit_offset() { #[actix_rt::test] async fn federation_formatting() { let server = Server::new_shared(); - let index = server.unique_index(); - - let nested_index = server.unique_index(); - let score_index = server.unique_index(); + let index = shared_index_with_documents().await; + let nested_index = shared_index_with_nested_documents().await; + let score_index = shared_index_with_score_documents().await; { let (response, code) = server @@ -2864,7 +2863,7 @@ async fn federation_formatting() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -2991,7 +2990,7 @@ async fn federation_formatting() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 12 @@ -3016,7 +3015,7 @@ async fn federation_formatting() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3028,7 +3027,7 @@ async fn federation_formatting() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 1, "offset": 0, "estimatedTotalHits": 12 @@ -3053,7 +3052,7 @@ async fn federation_formatting() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3137,7 +3136,7 @@ async fn federation_formatting() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 2, "estimatedTotalHits": 12 @@ -3162,10 +3161,10 @@ async fn federation_formatting() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 12, "estimatedTotalHits": 12 @@ -3197,7 +3196,7 @@ async fn federation_invalid_weight() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Invalid value at `.queries[1].federationOptions.weight`: the value of `weight` is invalid, expected a positive float (>= 0.0).", "code": "invalid_multi_search_weight", @@ -3211,7 +3210,7 @@ async fn federation_invalid_weight() { async fn federation_null_weight() { let server = Server::new_shared(); - let index = server.unique_index(); + let index = server.unique_index_with_prefix("fruits"); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -3231,7 +3230,7 @@ async fn federation_null_weight() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -3239,7 +3238,7 @@ async fn federation_null_weight() { "id": "red-delicious-boosted", "BOOST": true, "_federation": { - "indexUid": "[uuid]", + "indexUid": "fruits-[uuid]", "queriesPosition": 0, "weightedRankingScore": 2.7281746031746033 }, @@ -3250,7 +3249,7 @@ async fn federation_null_weight() { "id": "green-apple-boosted", "BOOST": true, "_federation": { - "indexUid": "[uuid]", + "indexUid": "fruits-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.318181818181818 }, @@ -3260,14 +3259,14 @@ async fn federation_null_weight() { "name": "Red apple gala", "id": "red-apple-gala", "_federation": { - "indexUid": "[uuid]", + "indexUid": "fruits-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.0 }, "_rankingScore": 0.953042328042328 } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3 @@ -3279,7 +3278,7 @@ async fn federation_null_weight() { async fn federation_federated_contains_pagination() { let server = Server::new_shared(); - let index = server.unique_index(); + let index = server.unique_index_with_prefix("fruits"); let documents = FRUITS_DOCUMENTS.clone(); let (value, _) = index.add_documents(documents, None).await; @@ -3293,7 +3292,7 @@ async fn federation_federated_contains_pagination() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Inside `.queries[1]`: Using pagination options is not allowed in federated queries.\n - Hint: remove `limit` from query #1 or remove `federation` from the request\n - Hint: pass `federation.limit` and `federation.offset` for pagination in federated search", "code": "invalid_multi_search_query_pagination", @@ -3309,7 +3308,7 @@ async fn federation_federated_contains_pagination() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Inside `.queries[1]`: Using pagination options is not allowed in federated queries.\n - Hint: remove `offset` from query #1 or remove `federation` from the request\n - Hint: pass `federation.limit` and `federation.offset` for pagination in federated search", "code": "invalid_multi_search_query_pagination", @@ -3325,7 +3324,7 @@ async fn federation_federated_contains_pagination() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Inside `.queries[1]`: Using pagination options is not allowed in federated queries.\n - Hint: remove `page` from query #1 or remove `federation` from the request\n - Hint: pass `federation.limit` and `federation.offset` for pagination in federated search", "code": "invalid_multi_search_query_pagination", @@ -3341,7 +3340,7 @@ async fn federation_federated_contains_pagination() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Inside `.queries[1]`: Using pagination options is not allowed in federated queries.\n - Hint: remove `hitsPerPage` from query #1 or remove `federation` from the request\n - Hint: pass `federation.limit` and `federation.offset` for pagination in federated search", "code": "invalid_multi_search_query_pagination", @@ -3355,7 +3354,7 @@ async fn federation_federated_contains_pagination() { async fn federation_federated_contains_facets() { let server = Server::new_shared(); - let index = server.unique_index(); + let index = server.unique_index_with_prefix("fruits"); let (value, _) = index .update_settings( @@ -3377,14 +3376,14 @@ async fn federation_federated_contains_facets() { ]})) .await; snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "name": "Red apple gala", "id": "red-apple-gala", "_federation": { - "indexUid": "[uuid]", + "indexUid": "fruits-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.953042328042328 } @@ -3394,7 +3393,7 @@ async fn federation_federated_contains_facets() { "id": "red-delicious-boosted", "BOOST": true, "_federation": { - "indexUid": "[uuid]", + "indexUid": "fruits-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9093915343915344 } @@ -3404,13 +3403,13 @@ async fn federation_federated_contains_facets() { "id": "green-apple-boosted", "BOOST": true, "_federation": { - "indexUid": "[uuid]", + "indexUid": "fruits-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.4393939393939394 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3 @@ -3425,7 +3424,7 @@ async fn federation_federated_contains_facets() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response), @r###" { "message": "Inside `.queries[1]`: Using facet options is not allowed in federated queries.\n - Hint: remove `facets` from query #1 or remove `federation` from the request\n - Hint: pass `federation.facetsByIndex.fruits: [\"BOOSTED\"]` for facets in federated search", "code": "invalid_multi_search_query_facets", @@ -3439,7 +3438,7 @@ async fn federation_federated_contains_facets() { async fn federation_non_faceted_for_an_index() { let server = Server::new_shared(); - let fruits_index = server.unique_index(); + let fruits_index = server.unique_index_with_prefix("fruits"); let (value, _) = fruits_index .update_settings( @@ -3449,7 +3448,7 @@ async fn federation_non_faceted_for_an_index() { fruits_index.wait_task(value.uid()).await.succeeded(); - let fruits_no_name_index = server.unique_index(); + let fruits_no_name_index = server.unique_index_with_prefix("fruits-no-name"); let (value, _) = fruits_no_name_index .update_settings( @@ -3459,7 +3458,7 @@ async fn federation_non_faceted_for_an_index() { fruits_no_name_index.wait_task(value.uid()).await.succeeded(); - let fruits_no_facets_index = server.unique_index(); + let fruits_no_facets_index = server.unique_index_with_prefix("fruits-no-facets"); let (value, _) = fruits_no_facets_index.update_settings(json!({"searchableAttributes": ["name"]})).await; @@ -3483,9 +3482,9 @@ async fn federation_non_faceted_for_an_index() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.federation.facetsByIndex.fruits-no-name`: Invalid facet distribution: Attribute `name` is not filterable. Available filterable attributes patterns are: `BOOST, id`.\n - Note: index `fruits-no-name` used in `.queries[1]`", + "message": "Inside `.federation.facetsByIndex.fruits-no-name-[uuid]`: Invalid facet distribution: Attribute `name` is not filterable. Available filterable attributes patterns are: `BOOST, id`.\n - Note: index `fruits-no-name-[uuid]` used in `.queries[1]`", "code": "invalid_multi_search_facets", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facets" @@ -3505,9 +3504,9 @@ async fn federation_non_faceted_for_an_index() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.federation.facetsByIndex.fruits-no-name`: Invalid facet distribution: Attribute `name` is not filterable. Available filterable attributes patterns are: `BOOST, id`.\n - Note: index `fruits-no-name` is not used in queries", + "message": "Inside `.federation.facetsByIndex.fruits-no-name-[uuid]`: Invalid facet distribution: Attribute `name` is not filterable. Available filterable attributes patterns are: `BOOST, id`.\n - Note: index `fruits-no-name-[uuid]` is not used in queries", "code": "invalid_multi_search_facets", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facets" @@ -3528,9 +3527,9 @@ async fn federation_non_faceted_for_an_index() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r#" + snapshot!(json_string!(response), @r#" { - "message": "Inside `.federation.facetsByIndex.fruits-no-facets`: Invalid facet distribution: Attributes `BOOST, id` are not filterable. This index does not have configured filterable attributes.\n - Note: index `fruits-no-facets` is not used in queries", + "message": "Inside `.federation.facetsByIndex.fruits-no-facets-[uuid]`: Invalid facet distribution: Attributes `BOOST, id` are not filterable. This index does not have configured filterable attributes.\n - Note: index `fruits-no-facets-[uuid]` is not used in queries", "code": "invalid_multi_search_facets", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facets" @@ -3550,7 +3549,7 @@ async fn federation_non_faceted_for_an_index() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Inside `.federation.facetsByIndex.zorglub`: Index `zorglub` not found.\n - Note: index `zorglub` is not used in queries", "code": "index_not_found", @@ -3578,7 +3577,7 @@ async fn federation_non_federated_contains_federation_option() { ]})) .await; snapshot!(code, @"400 Bad Request"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" + snapshot!(response, @r###" { "message": "Inside `.queries[1]`: Using `federationOptions` is not allowed in a non-federated search.\n - Hint: remove `federationOptions` from query #1 or add `federation` to the request.", "code": "invalid_multi_search_federation_options", @@ -3621,7 +3620,7 @@ async fn federation_vector_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3661,7 +3660,7 @@ async fn federation_vector_single_index() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4, @@ -3678,7 +3677,7 @@ async fn federation_vector_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3718,7 +3717,7 @@ async fn federation_vector_single_index() { } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4, @@ -3736,7 +3735,7 @@ async fn federation_vector_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3780,7 +3779,7 @@ async fn federation_vector_single_index() { "_rankingScore": "[score]" } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4, @@ -3793,7 +3792,7 @@ async fn federation_vector_single_index() { async fn federation_vector_two_indexes() { let server = Server::new_shared(); - let vectors_animal_index = server.unique_index(); + let vectors_animal_index = server.unique_index_with_prefix("vectors-animal"); let (value, _) = vectors_animal_index .update_settings(json!({"embedders": { @@ -3810,7 +3809,7 @@ async fn federation_vector_two_indexes() { snapshot!(code, @"202 Accepted"); vectors_animal_index.wait_task(value.uid()).await.succeeded(); - let vectors_sentiment_index = server.unique_index(); + let vectors_sentiment_index = server.unique_index_with_prefix("vectors-sentiment"); let (value, _) = vectors_sentiment_index .update_settings(json!({"embedders": { @@ -3836,7 +3835,7 @@ async fn federation_vector_two_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3859,7 +3858,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.979868710041046 } @@ -3884,7 +3883,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9728479385375975 } @@ -3909,7 +3908,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 } @@ -3934,7 +3933,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9242424242424242 } @@ -3959,7 +3958,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9242424242424242 } @@ -3984,7 +3983,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 } @@ -4009,7 +4008,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8432406187057495 } @@ -4034,13 +4033,13 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.6690993905067444 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 8, @@ -4056,7 +4055,7 @@ async fn federation_vector_two_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -4079,7 +4078,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9728479385375975 }, @@ -4105,7 +4104,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 }, @@ -4131,7 +4130,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9522157907485962 }, @@ -4157,7 +4156,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8719604015350342 }, @@ -4183,7 +4182,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 }, @@ -4209,7 +4208,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8432406187057495 }, @@ -4235,7 +4234,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8297949433326721 }, @@ -4261,14 +4260,14 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "[uuid]", + "indexUid": "vectors-sentiment-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.18887794017791748 }, "_rankingScore": "[score]" } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 8, @@ -4281,7 +4280,7 @@ async fn federation_vector_two_indexes() { async fn federation_facets_different_indexes_same_facet() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -4303,7 +4302,7 @@ async fn federation_facets_different_indexes_same_facet() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -4325,7 +4324,7 @@ async fn federation_facets_different_indexes_same_facet() { .await; batman_index.wait_task(value.uid()).await.succeeded(); - let batman_2_index = server.unique_index(); + let batman_2_index = server.unique_index_with_prefix("batman-2"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_2_index.add_documents(documents, None).await; @@ -4362,13 +4361,13 @@ async fn federation_facets_different_indexes_same_facet() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4376,7 +4375,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4384,7 +4383,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4392,7 +4391,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4400,7 +4399,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4408,7 +4407,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4416,7 +4415,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4424,7 +4423,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4432,7 +4431,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4440,7 +4439,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4448,7 +4447,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4456,7 +4455,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Escape Room", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4464,7 +4463,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Gläss", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4472,7 +4471,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4480,18 +4479,18 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Shazam!", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 15, "facetsByIndex": { - "batman": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4503,7 +4502,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "batman-2": { + "batman-2-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4515,7 +4514,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "movies": { + "movies-[uuid]": { "distribution": { "color": { "blue": 3, @@ -4552,13 +4551,13 @@ async fn federation_facets_different_indexes_same_facet() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4566,7 +4565,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4574,7 +4573,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4582,7 +4581,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4590,7 +4589,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4598,7 +4597,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4606,7 +4605,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4614,7 +4613,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4622,7 +4621,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -4630,7 +4629,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4638,7 +4637,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4646,7 +4645,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Escape Room", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4654,7 +4653,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Gläss", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4662,7 +4661,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -4670,13 +4669,13 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Shazam!", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 15, @@ -4714,13 +4713,13 @@ async fn federation_facets_different_indexes_same_facet() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 2, "weightedRankingScore": 0.9848484848484848 } @@ -4728,7 +4727,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 3, "weightedRankingScore": 0.9528218694885362 } @@ -4736,7 +4735,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.7028218694885362 } @@ -4744,7 +4743,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 3, "weightedRankingScore": 0.9528218694885362 } @@ -4752,7 +4751,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.7028218694885362 } @@ -4760,7 +4759,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8317901234567902 } @@ -4768,7 +4767,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8317901234567902 } @@ -4776,7 +4775,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.23106060606060605 } @@ -4784,7 +4783,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.23106060606060605 } @@ -4792,7 +4791,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.5 } @@ -4800,18 +4799,18 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.5 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 11, "facetsByIndex": { - "batman": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4823,7 +4822,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "batman-2": { + "batman-2-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4835,7 +4834,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "movies": { + "movies-[uuid]": { "distribution": {}, "stats": {} } @@ -4848,7 +4847,7 @@ async fn federation_facets_different_indexes_same_facet() { async fn federation_facets_same_indexes() { let server = Server::new_shared(); - let doggos_index = server.unique_index(); + let doggos_index = server.unique_index_with_prefix("doggos"); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = doggos_index.add_documents(documents, None).await; @@ -4869,7 +4868,7 @@ async fn federation_facets_same_indexes() { .await; doggos_index.wait_task(value.uid()).await.succeeded(); - let doggos2_index = server.unique_index(); + let doggos2_index = server.unique_index_with_prefix("doggos-2"); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = doggos2_index.add_documents(documents, None).await; @@ -4901,13 +4900,13 @@ async fn federation_facets_same_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "id": 852, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -4915,7 +4914,7 @@ async fn federation_facets_same_indexes() { { "id": 951, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -4923,18 +4922,18 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 3, "facetsByIndex": { - "doggos": { + "doggos-[uuid]": { "distribution": { "doggos.age": { "2": 1, @@ -4975,13 +4974,13 @@ async fn federation_facets_same_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "hits": [ { "id": 852, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -4989,7 +4988,7 @@ async fn federation_facets_same_indexes() { { "id": 951, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -4997,7 +4996,7 @@ async fn federation_facets_same_indexes() { { "id": 852, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5005,18 +5004,18 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4, "facetsByIndex": { - "doggos": { + "doggos-[uuid]": { "distribution": { "doggos.age": { "2": 1, @@ -5040,7 +5039,7 @@ async fn federation_facets_same_indexes() { } } }, - "doggos-2": { + "doggos-2-[uuid]": { "distribution": { "doggos.age": { "2": 1, @@ -5078,13 +5077,13 @@ async fn federation_facets_same_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "hits": [ { "id": 852, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5092,7 +5091,7 @@ async fn federation_facets_same_indexes() { { "id": 951, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9621212121212122 } @@ -5100,7 +5099,7 @@ async fn federation_facets_same_indexes() { { "id": 852, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5108,13 +5107,13 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "[uuid]", + "indexUid": "doggos-2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 4, @@ -5149,7 +5148,7 @@ async fn federation_facets_same_indexes() { async fn federation_inconsistent_merge_order() { let server = Server::new_shared(); - let movies_index = server.unique_index(); + let movies_index = server.unique_index_with_prefix("movies"); let documents = DOCUMENTS.clone(); let (value, _) = movies_index.add_documents(documents, None).await; @@ -5171,7 +5170,7 @@ async fn federation_inconsistent_merge_order() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let movies2_index = server.unique_index(); + let movies2_index = server.unique_index_with_prefix("movies-2"); let documents = DOCUMENTS.clone(); let (value, _) = movies2_index.add_documents(documents, None).await; @@ -5196,7 +5195,7 @@ async fn federation_inconsistent_merge_order() { .await; movies2_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index(); + let batman_index = server.unique_index_with_prefix("batman"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_index.add_documents(documents, None).await; @@ -5233,13 +5232,13 @@ async fn federation_inconsistent_merge_order() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5247,7 +5246,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5255,7 +5254,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5263,7 +5262,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5271,7 +5270,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5279,7 +5278,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5287,7 +5286,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5295,7 +5294,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5303,7 +5302,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5311,7 +5310,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5319,7 +5318,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5327,7 +5326,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5335,7 +5334,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5343,7 +5342,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5351,18 +5350,18 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 15, "facetsByIndex": { - "batman": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -5374,7 +5373,7 @@ async fn federation_inconsistent_merge_order() { }, "stats": {} }, - "movies": { + "movies-[uuid]": { "distribution": { "color": { "blue": 3, @@ -5392,7 +5391,7 @@ async fn federation_inconsistent_merge_order() { }, "stats": {} }, - "movies-2": { + "movies-2-[uuid]": { "distribution": { "color": { "red": 3, @@ -5430,9 +5429,9 @@ async fn federation_inconsistent_merge_order() { ]})) .await; snapshot!(code, @"400 Bad Request"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { - "message": "Inside `.federation.facetsByIndex.movies-2`: Inconsistent order for values in facet `color`: index `[uuid]` orders alphabetically, but index `[uuid]` orders by count.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `[uuid]` used in `.queries[2]`", + "message": "Inside `.federation.facetsByIndex.movies-2-[uuid]`: Inconsistent order for values in facet `color`: index `movies-[uuid]` orders alphabetically, but index `movies-2-[uuid]` orders by count.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `movies-2-[uuid]` used in `.queries[2]`", "code": "invalid_multi_search_facet_order", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facet_order" @@ -5457,13 +5456,13 @@ async fn federation_inconsistent_merge_order() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###" + snapshot!(json_string!(response), @r###" { "hits": [ { "title": "Badman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5471,7 +5470,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5479,7 +5478,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman Returns", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5487,7 +5486,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5495,7 +5494,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "[uuid]", + "indexUid": "batman-[uuid]", "queriesPosition": 1, "weightedRankingScore": 1.0 } @@ -5503,7 +5502,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5511,7 +5510,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5519,7 +5518,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5527,7 +5526,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5535,7 +5534,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5543,7 +5542,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5551,7 +5550,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5559,7 +5558,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5567,7 +5566,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-[uuid]", "queriesPosition": 0, "weightedRankingScore": 1.0 } @@ -5575,13 +5574,13 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "[uuid]", + "indexUid": "movies-2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } } ], - "processingTimeMs": "[time]", + "processingTimeMs": "[duration]", "limit": 20, "offset": 0, "estimatedTotalHits": 15, From 8a916a4e42a328c21fdcff8ac9d3629884813c05 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 07:54:04 +0300 Subject: [PATCH 05/17] More assertion fixes Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 122 +++++++++---------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index d75a09364..9ddf938fc 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -100,7 +100,7 @@ async fn simple_search_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response["results"], { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response["results"], { ".**.processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" [ { "indexUid": "SHARED_DOCUMENTS", @@ -199,7 +199,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -208,7 +208,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 1.0 } @@ -217,7 +217,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.9848484848484848 } @@ -226,7 +226,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.9848484848484848 } @@ -235,7 +235,7 @@ async fn federation_multiple_search_single_index() { "title": "Badman", "id": "E", "_federation": { - "indexUid": "test", + "indexUid": "SHARED_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.5 } @@ -393,7 +393,7 @@ async fn simple_search_two_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response["results"], { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response["results"], { ".**.processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" [ { "indexUid": "SHARED_DOCUMENTS", @@ -1616,7 +1616,7 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested-[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested.rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #0 and #1 are incompatible: \n 1. `queries[0].sort[0]`, `nested-[uuid].rankingRules[0]`: ascending sort rule(s) on field `mother`\n 2. `queries[1].sort[0]`, `nested-[uuid].rankingRules[0]`: descending sort rule(s) on field `father`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2089,7 +2089,7 @@ async fn federation_sort_different_ranking_rules() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `batman-[uuid].rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `batman-[uuid].rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `movies-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2153,7 +2153,7 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n 2. `queries[0].sort[0]`, `batman-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n 2. `queries[0].sort[0]`, `movies-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2171,7 +2171,7 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `batman-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n 2. `queries[1].sort[0]`, `movies-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2505,7 +2505,7 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[0].sort[0]`, `batman-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", + "message": "Inside `.queries[0]`: The results of queries #1 and #0 are incompatible: \n 1. `queries[1].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[0].sort[0]`, `movies-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n - note: The ranking rules of query #1 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n - note: The ranking rules of query #0 were modified during canonicalization:\n 1. Removed relevancy rule `words` at position #1 in ranking rules because the query is a placeholder search (`q`: \"\")\n 2. Removed relevancy rule `typo` at position #2 in ranking rules because the query is a placeholder search (`q`: \"\")\n 3. Removed relevancy rule `proximity` at position #3 in ranking rules because the query is a placeholder search (`q`: \"\")\n 4. Removed relevancy rule `attribute` at position #4 in ranking rules because the query is a placeholder search (`q`: \"\")\n 5. Removed relevancy rule `exactness` at position #5 in ranking rules because the query is a placeholder search (`q`: \"\")\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2523,7 +2523,7 @@ async fn federation_sort_different_indexes_different_criterion_opposite_directio snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[1].sort[0]`, `[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2].sort[0]`, `batman-[uuid].rankingRules[0]`: descending sort rule(s) on field `id`\n 2. `queries[1].sort[0]`, `movies-[uuid].rankingRules[0]`: ascending sort rule(s) on field `title`\n - cannot compare two sort rules in opposite directions\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" @@ -2681,7 +2681,7 @@ async fn federation_limit_offset() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -2718,7 +2718,7 @@ async fn federation_limit_offset() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -2827,7 +2827,7 @@ async fn federation_limit_offset() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [], "processingTimeMs": "[duration]", @@ -3052,7 +3052,7 @@ async fn federation_formatting() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -3161,7 +3161,7 @@ async fn federation_formatting() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [], "processingTimeMs": "[duration]", @@ -3426,7 +3426,7 @@ async fn federation_federated_contains_facets() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Using facet options is not allowed in federated queries.\n - Hint: remove `facets` from query #1 or remove `federation` from the request\n - Hint: pass `federation.facetsByIndex.fruits: [\"BOOSTED\"]` for facets in federated search", + "message": "Inside `.queries[1]`: Using facet options is not allowed in federated queries.\n - Hint: remove `facets` from query #1 or remove `federation` from the request\n - Hint: pass `federation.facetsByIndex.fruits-[uuid]: [\"BOOSTED\"]` for facets in federated search", "code": "invalid_multi_search_query_facets", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_facets" @@ -3735,7 +3735,7 @@ async fn federation_vector_single_index() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -4055,7 +4055,7 @@ async fn federation_vector_two_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response, { ".**._rankingScore" => "[score]" }), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { "hits": [ { @@ -4078,7 +4078,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment-[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9728479385375975 }, @@ -4104,7 +4104,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment-[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.9701486229896544 }, @@ -4182,7 +4182,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment-[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8601469993591309 }, @@ -4208,7 +4208,7 @@ async fn federation_vector_two_indexes() { } }, "_federation": { - "indexUid": "vectors-sentiment-[uuid]", + "indexUid": "vectors-animal-[uuid]", "queriesPosition": 0, "weightedRankingScore": 0.8432406187057495 }, @@ -4490,7 +4490,7 @@ async fn federation_facets_different_indexes_same_facet() { "offset": 0, "estimatedTotalHits": 15, "facetsByIndex": { - "batman-[uuid]": { + "batman-2-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4502,7 +4502,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "batman-2-[uuid]": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4810,7 +4810,7 @@ async fn federation_facets_different_indexes_same_facet() { "offset": 0, "estimatedTotalHits": 11, "facetsByIndex": { - "batman-[uuid]": { + "batman-2-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4822,7 +4822,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "batman-2-[uuid]": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4974,7 +4974,7 @@ async fn federation_facets_same_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -5015,6 +5015,27 @@ async fn federation_facets_same_indexes() { "offset": 0, "estimatedTotalHits": 4, "facetsByIndex": { + "doggos-2-[uuid]": { + "distribution": { + "doggos.age": { + "2": 1, + "4": 1 + }, + "father": { + "jean": 1, + "romain": 1 + }, + "mother": { + "michelle": 2 + } + }, + "stats": { + "doggos.age": { + "min": 2.0, + "max": 4.0 + } + } + }, "doggos-[uuid]": { "distribution": { "doggos.age": { @@ -5038,27 +5059,6 @@ async fn federation_facets_same_indexes() { "max": 6.0 } } - }, - "doggos-2-[uuid]": { - "distribution": { - "doggos.age": { - "2": 1, - "4": 1 - }, - "father": { - "jean": 1, - "romain": 1 - }, - "mother": { - "michelle": 2 - } - }, - "stats": { - "doggos.age": { - "min": 2.0, - "max": 4.0 - } - } } } } @@ -5077,7 +5077,7 @@ async fn federation_facets_same_indexes() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -5373,13 +5373,13 @@ async fn federation_inconsistent_merge_order() { }, "stats": {} }, - "movies-[uuid]": { + "movies-2-[uuid]": { "distribution": { "color": { - "blue": 3, - "green": 2, "red": 3, - "yellow": 2 + "blue": 3, + "yellow": 2, + "green": 2 }, "title": { "Captain Marvel": 1, @@ -5391,13 +5391,13 @@ async fn federation_inconsistent_merge_order() { }, "stats": {} }, - "movies-2-[uuid]": { + "movies-[uuid]": { "distribution": { "color": { - "red": 3, "blue": 3, - "yellow": 2, - "green": 2 + "green": 2, + "red": 3, + "yellow": 2 }, "title": { "Captain Marvel": 1, @@ -5431,7 +5431,7 @@ async fn federation_inconsistent_merge_order() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.federation.facetsByIndex.movies-2-[uuid]`: Inconsistent order for values in facet `color`: index `movies-[uuid]` orders alphabetically, but index `movies-2-[uuid]` orders by count.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `movies-2-[uuid]` used in `.queries[2]`", + "message": "Inside `.federation.facetsByIndex.movies-[uuid]`: Inconsistent order for values in facet `color`: index `movies-2-[uuid]` orders by count, but index `movies-[uuid]` orders alphabetically.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `movies-[uuid]` used in `.queries[0]`", "code": "invalid_multi_search_facet_order", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facet_order" From 0263eb0aec85f34e42d9e781f0bb2aba60d027e7 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 08:42:35 +0300 Subject: [PATCH 06/17] More assertion fixes Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 152 +++++++++---------- 1 file changed, 75 insertions(+), 77 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 9ddf938fc..86b40e601 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -181,7 +181,7 @@ async fn federation_single_search_single_index() { #[actix_rt::test] async fn federation_multiple_search_single_index() { let server = Server::new_shared(); - let index = shared_index_with_documents().await; + let index = shared_index_with_score_documents().await; let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ @@ -199,7 +199,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "SHARED_DOCUMENTS", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -208,7 +208,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "SHARED_DOCUMENTS", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 3, "weightedRankingScore": 1.0 } @@ -217,7 +217,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "SHARED_DOCUMENTS", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.9848484848484848 } @@ -226,7 +226,7 @@ async fn federation_multiple_search_single_index() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "SHARED_DOCUMENTS", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 2, "weightedRankingScore": 0.9848484848484848 } @@ -235,7 +235,7 @@ async fn federation_multiple_search_single_index() { "title": "Badman", "id": "E", "_federation": { - "indexUid": "SHARED_DOCUMENTS", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 0.5 } @@ -880,14 +880,13 @@ async fn federation_one_query_sort_error() { let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ {"indexUid" : index.uid, "q": "glass"}, - {"indexUid": nested_index.uid, "q": "pésti", "sort": ["doggos:desc"]}, + {"indexUid": nested_index.uid, "q": "pésti", "sort": ["mother:desc"]}, ]})) .await; - dbg!(&response); snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `nested`: Attribute `doggos` is not sortable. This index does not have configured sortable attributes.", + "message": "Inside `.queries[1]`: Index `SHARED_NESTED_DOCUMENTS`: Attribute `mother` is not sortable. Available sortable attributes are: `doggos`.", "code": "invalid_search_sort", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_search_sort" @@ -2554,7 +2553,6 @@ async fn federation_limit_offset() { {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]}, ]})) .await; - dbg!(&response); snapshot!(code, @"200 OK"); snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" { @@ -4324,7 +4322,7 @@ async fn federation_facets_different_indexes_same_facet() { .await; batman_index.wait_task(value.uid()).await.succeeded(); - let batman_2_index = server.unique_index_with_prefix("batman-2"); + let batman_2_index = server.unique_index_with_prefix("batman_2"); let documents = SCORE_DOCUMENTS.clone(); let (value, _) = batman_2_index.add_documents(documents, None).await; @@ -4375,7 +4373,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4391,7 +4389,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4407,7 +4405,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4423,7 +4421,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4439,7 +4437,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4490,7 +4488,7 @@ async fn federation_facets_different_indexes_same_facet() { "offset": 0, "estimatedTotalHits": 15, "facetsByIndex": { - "batman-2-[uuid]": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4502,7 +4500,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "batman-[uuid]": { + "batman_2-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4565,7 +4563,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4581,7 +4579,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4597,7 +4595,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4613,7 +4611,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4629,7 +4627,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -4735,7 +4733,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 2", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.7028218694885362 } @@ -4751,7 +4749,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman the dark knight returns: Part 1", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.7028218694885362 } @@ -4767,7 +4765,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman Returns", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.8317901234567902 } @@ -4783,7 +4781,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Batman", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.23106060606060605 } @@ -4799,7 +4797,7 @@ async fn federation_facets_different_indexes_same_facet() { { "title": "Badman", "_federation": { - "indexUid": "batman-2-[uuid]", + "indexUid": "batman_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.5 } @@ -4810,7 +4808,7 @@ async fn federation_facets_different_indexes_same_facet() { "offset": 0, "estimatedTotalHits": 11, "facetsByIndex": { - "batman-2-[uuid]": { + "batman-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4822,7 +4820,7 @@ async fn federation_facets_different_indexes_same_facet() { }, "stats": {} }, - "batman-[uuid]": { + "batman_2-[uuid]": { "distribution": { "title": { "Badman": 1, @@ -4868,7 +4866,7 @@ async fn federation_facets_same_indexes() { .await; doggos_index.wait_task(value.uid()).await.succeeded(); - let doggos2_index = server.unique_index_with_prefix("doggos-2"); + let doggos2_index = server.unique_index_with_prefix("doggos_2"); let documents = NESTED_DOCUMENTS.clone(); let (value, _) = doggos2_index.add_documents(documents, None).await; @@ -4996,7 +4994,7 @@ async fn federation_facets_same_indexes() { { "id": 852, "_federation": { - "indexUid": "doggos-2-[uuid]", + "indexUid": "doggos_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5004,7 +5002,7 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "doggos-2-[uuid]", + "indexUid": "doggos_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5015,27 +5013,6 @@ async fn federation_facets_same_indexes() { "offset": 0, "estimatedTotalHits": 4, "facetsByIndex": { - "doggos-2-[uuid]": { - "distribution": { - "doggos.age": { - "2": 1, - "4": 1 - }, - "father": { - "jean": 1, - "romain": 1 - }, - "mother": { - "michelle": 2 - } - }, - "stats": { - "doggos.age": { - "min": 2.0, - "max": 4.0 - } - } - }, "doggos-[uuid]": { "distribution": { "doggos.age": { @@ -5059,6 +5036,27 @@ async fn federation_facets_same_indexes() { "max": 6.0 } } + }, + "doggos_2-[uuid]": { + "distribution": { + "doggos.age": { + "2": 1, + "4": 1 + }, + "father": { + "jean": 1, + "romain": 1 + }, + "mother": { + "michelle": 2 + } + }, + "stats": { + "doggos.age": { + "min": 2.0, + "max": 4.0 + } + } } } } @@ -5099,7 +5097,7 @@ async fn federation_facets_same_indexes() { { "id": 852, "_federation": { - "indexUid": "doggos-2-[uuid]", + "indexUid": "doggos_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5107,7 +5105,7 @@ async fn federation_facets_same_indexes() { { "id": 750, "_federation": { - "indexUid": "doggos-2-[uuid]", + "indexUid": "doggos_2-[uuid]", "queriesPosition": 1, "weightedRankingScore": 0.9621212121212122 } @@ -5170,7 +5168,7 @@ async fn federation_inconsistent_merge_order() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let movies2_index = server.unique_index_with_prefix("movies-2"); + let movies2_index = server.unique_index_with_prefix("movies_2"); let documents = DOCUMENTS.clone(); let (value, _) = movies2_index.add_documents(documents, None).await; @@ -5286,7 +5284,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5302,7 +5300,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5318,7 +5316,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5334,7 +5332,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5350,7 +5348,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5373,13 +5371,13 @@ async fn federation_inconsistent_merge_order() { }, "stats": {} }, - "movies-2-[uuid]": { + "movies-[uuid]": { "distribution": { "color": { - "red": 3, "blue": 3, - "yellow": 2, - "green": 2 + "green": 2, + "red": 3, + "yellow": 2 }, "title": { "Captain Marvel": 1, @@ -5391,13 +5389,13 @@ async fn federation_inconsistent_merge_order() { }, "stats": {} }, - "movies-[uuid]": { + "movies_2-[uuid]": { "distribution": { "color": { - "blue": 3, - "green": 2, "red": 3, - "yellow": 2 + "blue": 3, + "yellow": 2, + "green": 2 }, "title": { "Captain Marvel": 1, @@ -5431,7 +5429,7 @@ async fn federation_inconsistent_merge_order() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.federation.facetsByIndex.movies-[uuid]`: Inconsistent order for values in facet `color`: index `movies-2-[uuid]` orders by count, but index `movies-[uuid]` orders alphabetically.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `movies-[uuid]` used in `.queries[0]`", + "message": "Inside `.federation.facetsByIndex.movies_2-[uuid]`: Inconsistent order for values in facet `color`: index `movies-[uuid]` orders alphabetically, but index `movies_2-[uuid]` orders by count.\n - Hint: Remove `federation.mergeFacets` or change `faceting.sortFacetValuesBy` to be consistent in settings.\n - Note: index `movies_2-[uuid]` used in `.queries[2]`", "code": "invalid_multi_search_facet_order", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facet_order" @@ -5456,7 +5454,7 @@ async fn federation_inconsistent_merge_order() { ]})) .await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(response), @r###" + snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###" { "hits": [ { @@ -5510,7 +5508,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Captain Marvel", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5526,7 +5524,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Escape Room", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5542,7 +5540,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Gläss", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5558,7 +5556,7 @@ async fn federation_inconsistent_merge_order() { { "title": "How to Train Your Dragon: The Hidden World", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } @@ -5574,7 +5572,7 @@ async fn federation_inconsistent_merge_order() { { "title": "Shazam!", "_federation": { - "indexUid": "movies-2-[uuid]", + "indexUid": "movies_2-[uuid]", "queriesPosition": 2, "weightedRankingScore": 1.0 } From bb4baf7fae78311e65db47b1949c5a0884d8b86e Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 08:52:28 +0300 Subject: [PATCH 07/17] Remove useless dynamic redactions. They are covered by their `.**.xyz` counterparts Signed-off-by: Martin Tzvetanov Grigorov --- crates/meili-snap/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/meili-snap/src/lib.rs b/crates/meili-snap/src/lib.rs index fcd17879e..3c838f6d6 100644 --- a/crates/meili-snap/src/lib.rs +++ b/crates/meili-snap/src/lib.rs @@ -62,9 +62,7 @@ pub fn default_snapshot_settings_for_test<'a>( } } - settings.add_dynamic_redaction(".message", uuid_in_message_redaction); settings.add_dynamic_redaction(".**.message", uuid_in_message_redaction); - settings.add_dynamic_redaction(".indexUid", uuid_in_message_redaction); settings.add_dynamic_redaction(".**.indexUid", uuid_in_message_redaction); settings.add_dynamic_redaction(".facetsByIndex", uuid_in_json_key_redaction); From 824f5b12cec4119ef04250fbd8002b00a2aeca9d Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 08:54:58 +0300 Subject: [PATCH 08/17] Formatting Signed-off-by: Martin Tzvetanov Grigorov --- crates/meili-snap/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/meili-snap/src/lib.rs b/crates/meili-snap/src/lib.rs index 3c838f6d6..e026f303a 100644 --- a/crates/meili-snap/src/lib.rs +++ b/crates/meili-snap/src/lib.rs @@ -46,16 +46,16 @@ pub fn default_snapshot_settings_for_test<'a>( fn uuid_in_json_key_redaction(content: Content, _content_path: ContentPath) -> Content { match content { Content::Map(map) => { - let new_map = map.iter() - .map(|(key, value)| { - match key { - Content::String(s) => { - let uuid_replaced = UUID_IN_MESSAGE_RE.replace_all(s, "[uuid]"); - (Content::String(uuid_replaced.to_string()), value.clone()) - } - _ => (key.clone(), value.clone()), + let new_map = map + .iter() + .map(|(key, value)| match key { + Content::String(s) => { + let uuid_replaced = UUID_IN_MESSAGE_RE.replace_all(s, "[uuid]"); + (Content::String(uuid_replaced.to_string()), value.clone()) } - }).collect(); + _ => (key.clone(), value.clone()), + }) + .collect(); Content::Map(new_map) } _ => content, From a73d3c03e99c08809c6f1ad73334c7c1197afb69 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 09:10:10 +0300 Subject: [PATCH 09/17] Make the dynamic assertion for `facetsByIndex` JSON key more broader Signed-off-by: Martin Tzvetanov Grigorov --- crates/meili-snap/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/meili-snap/src/lib.rs b/crates/meili-snap/src/lib.rs index e026f303a..efe57f8df 100644 --- a/crates/meili-snap/src/lib.rs +++ b/crates/meili-snap/src/lib.rs @@ -64,7 +64,7 @@ pub fn default_snapshot_settings_for_test<'a>( settings.add_dynamic_redaction(".**.message", uuid_in_message_redaction); settings.add_dynamic_redaction(".**.indexUid", uuid_in_message_redaction); - settings.add_dynamic_redaction(".facetsByIndex", uuid_in_json_key_redaction); + settings.add_dynamic_redaction(".**.facetsByIndex", uuid_in_json_key_redaction); let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name); let test_name = test_name.rsplit("::").next().unwrap().to_owned(); From 620867d611c5805e9ff9e31fd6c91953675ca9fa Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 11:01:05 +0300 Subject: [PATCH 10/17] Use unique indices for the searches in non-existing indices By using hardcoded there is a chance that the index could exist Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 86b40e601..a7489260d 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1,3 +1,4 @@ +use uuid::Uuid; use meili_snap::{json_string, snapshot}; use super::{DOCUMENTS, FRUITS_DOCUMENTS, NESTED_DOCUMENTS}; @@ -784,16 +785,19 @@ async fn federation_one_index_doesnt_exist() { async fn search_multiple_indexes_dont_exist() { let server = Server::new_shared(); + let index_1 = format!("index_1-{}", Uuid::new_v4()); + let index_2 = format!("index_2-{}", Uuid::new_v4()); + let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti"}, + {"indexUid" : index_1, "q": "glass"}, + {"indexUid": index_2, "q": "pésti"}, ]})) .await; snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Index `test` not found.", + "message": "Inside `.queries[0]`: Index `index_1-[uuid]` not found.", "code": "index_not_found", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#index_not_found" @@ -805,10 +809,13 @@ async fn search_multiple_indexes_dont_exist() { async fn federation_multiple_indexes_dont_exist() { let server = Server::new_shared(); + let index_1 = format!("index_1-{}", Uuid::new_v4()); + let index_2 = format!("index_2-{}", Uuid::new_v4()); + let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : "test", "q": "glass"}, - {"indexUid": "nested", "q": "pésti"}, + {"indexUid" : index_1, "q": "glass"}, + {"indexUid": index_2, "q": "pésti"}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -816,7 +823,7 @@ async fn federation_multiple_indexes_dont_exist() { // the query index is the lowest index with that index snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: Index `nested` not found.", + "message": "Inside `.queries[0]`: Index `index_1-[uuid]` not found.", "code": "index_not_found", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#index_not_found" From b8845d10157bb69979f1c762ad8f2b5c22423170 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 11 Jun 2025 11:29:33 +0300 Subject: [PATCH 11/17] Sort the imports Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index a7489260d..e862649f4 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1,5 +1,5 @@ -use uuid::Uuid; use meili_snap::{json_string, snapshot}; +use uuid::Uuid; use super::{DOCUMENTS, FRUITS_DOCUMENTS, NESTED_DOCUMENTS}; use crate::common::{ From 646e44ddf90a18c593d94db60a448c622e86578f Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Thu, 12 Jun 2025 08:59:19 +0300 Subject: [PATCH 12/17] Re-use the shared_index_with_score_documents since the settings are as the default Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 33 +++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index e862649f4..79b8952b1 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1924,26 +1924,7 @@ async fn federation_sort_different_ranking_rules() { .await; movies_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "words", - "typo", - "proximity", - "attribute", - "sort", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let batman_index = shared_index_with_score_documents().await; // return titles ordered across indexes let (response, code) = server @@ -1960,7 +1941,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Badman", "id": "E", "_federation": { - "indexUid": "batman-[uuid]", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1970,7 +1951,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman", "id": "D", "_federation": { - "indexUid": "batman-[uuid]", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1980,7 +1961,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman Returns", "id": "C", "_federation": { - "indexUid": "batman-[uuid]", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -1990,7 +1971,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman the dark knight returns: Part 1", "id": "A", "_federation": { - "indexUid": "batman-[uuid]", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2000,7 +1981,7 @@ async fn federation_sort_different_ranking_rules() { "title": "Batman the dark knight returns: Part 2", "id": "B", "_federation": { - "indexUid": "batman-[uuid]", + "indexUid": "SHARED_SCORE_DOCUMENTS", "queriesPosition": 1, "weightedRankingScore": 1.0 }, @@ -2095,7 +2076,7 @@ async fn federation_sort_different_ranking_rules() { snapshot!(code, @"400 Bad Request"); snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `batman-[uuid].rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `movies-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", + "message": "Inside `.queries[1]`: The results of queries #2 and #1 are incompatible: \n 1. `queries[2]`, `SHARED_SCORE_DOCUMENTS.rankingRules[0..=3]`: relevancy rule(s) words, typo, proximity, attribute\n 2. `queries[1].sort[0]`, `movies-[uuid].rankingRules[0]`: descending sort rule(s) on field `title`\n - cannot compare a relevancy rule with a sort rule\n", "code": "invalid_multi_search_query_ranking_rules", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_multi_search_query_ranking_rules" From e8774ad0798cedbea4b94bcf7346fe135f29ebbc Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Thu, 12 Jun 2025 13:46:17 +0300 Subject: [PATCH 13/17] Extract shared indices for movies and batman documents Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 352 ++++--------------- 1 file changed, 78 insertions(+), 274 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 79b8952b1..8c6e45c74 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1,16 +1,80 @@ use meili_snap::{json_string, snapshot}; +use tokio::sync::OnceCell; use uuid::Uuid; use super::{DOCUMENTS, FRUITS_DOCUMENTS, NESTED_DOCUMENTS}; +use crate::common::index::Index; use crate::common::{ shared_index_with_documents, shared_index_with_nested_documents, - shared_index_with_score_documents, Server, + shared_index_with_score_documents, Server, Shared, }; use crate::json; use crate::search::{SCORE_DOCUMENTS, VECTOR_DOCUMENTS}; mod proxy; +pub async fn shared_movies_index() -> &'static Index<'static, Shared> { + static INDEX: OnceCell> = OnceCell::const_new(); + INDEX + .get_or_init(|| async { + let server = Server::new_shared(); + let movies_index = server.unique_index_with_prefix("movies"); + + let documents = DOCUMENTS.clone(); + let (response, _code) = movies_index.add_documents(documents, None).await; + movies_index.wait_task(response.uid()).await.succeeded(); + + let (value, _) = movies_index + .update_settings(json!({ + "sortableAttributes": ["title"], + "filterableAttributes": ["title", "color"], + "rankingRules": [ + "sort", + "words", + "typo", + "proximity", + "attribute", + "exactness" + ] + })) + .await; + movies_index.wait_task(value.uid()).await.succeeded(); + movies_index.to_shared() + }) + .await +} + +pub async fn shared_batman_index() -> &'static Index<'static, Shared> { + static INDEX: OnceCell> = OnceCell::const_new(); + INDEX + .get_or_init(|| async { + let server = Server::new_shared(); + let batman_index = server.unique_index_with_prefix("batman"); + + let documents = SCORE_DOCUMENTS.clone(); + let (response, _code) = batman_index.add_documents(documents, None).await; + batman_index.wait_task(response.uid()).await.succeeded(); + + let (value, _) = batman_index + .update_settings(json!({ + "sortableAttributes": ["id", "title"], + "filterableAttributes": ["title"], + "rankingRules": [ + "sort", + "words", + "typo", + "proximity", + "attribute", + "exactness" + ] + })) + .await; + batman_index.wait_task(value.uid()).await.succeeded(); + batman_index.to_shared() + }) + .await +} + #[actix_rt::test] async fn search_empty_list() { let server = Server::new_shared(); @@ -1633,47 +1697,8 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() { #[actix_rt::test] async fn federation_sort_different_indexes_same_criterion_same_direction() { let server = Server::new_shared(); - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; + let batman_index = shared_batman_index().await; // return titles ordered across indexes let (response, code) = server @@ -1903,26 +1928,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() { async fn federation_sort_different_ranking_rules() { let server = Server::new_shared(); - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; let batman_index = shared_index_with_score_documents().await; @@ -2087,48 +2093,8 @@ async fn federation_sort_different_ranking_rules() { #[actix_rt::test] async fn federation_sort_different_indexes_same_criterion_opposite_direction() { let server = Server::new_shared(); - - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; + let batman_index = shared_batman_index().await; // all results from query 0 let (response, code) = server @@ -2169,48 +2135,8 @@ async fn federation_sort_different_indexes_same_criterion_opposite_direction() { #[actix_rt::test] async fn federation_sort_different_indexes_different_criterion_same_direction() { let server = Server::new_shared(); - - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["id"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; + let batman_index = shared_batman_index().await; // return titles ordered across indexes let (response, code) = server @@ -2439,48 +2365,8 @@ async fn federation_sort_different_indexes_different_criterion_same_direction() #[actix_rt::test] async fn federation_sort_different_indexes_different_criterion_opposite_direction() { let server = Server::new_shared(); - - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["id"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; + let batman_index = shared_batman_index().await; // all results from query 0 first let (response, code) = server @@ -4265,50 +4151,8 @@ async fn federation_vector_two_indexes() { #[actix_rt::test] async fn federation_facets_different_indexes_same_facet() { let server = Server::new_shared(); - - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "filterableAttributes": ["title", "color"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "filterableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; + let batman_index = shared_batman_index().await; let batman_2_index = server.unique_index_with_prefix("batman_2"); @@ -5134,27 +4978,7 @@ async fn federation_facets_same_indexes() { async fn federation_inconsistent_merge_order() { let server = Server::new_shared(); - let movies_index = server.unique_index_with_prefix("movies"); - - let documents = DOCUMENTS.clone(); - let (value, _) = movies_index.add_documents(documents, None).await; - movies_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = movies_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "filterableAttributes": ["title", "color"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - movies_index.wait_task(value.uid()).await.succeeded(); + let movies_index = shared_movies_index().await; let movies2_index = server.unique_index_with_prefix("movies_2"); @@ -5181,27 +5005,7 @@ async fn federation_inconsistent_merge_order() { .await; movies2_index.wait_task(value.uid()).await.succeeded(); - let batman_index = server.unique_index_with_prefix("batman"); - - let documents = SCORE_DOCUMENTS.clone(); - let (value, _) = batman_index.add_documents(documents, None).await; - batman_index.wait_task(value.uid()).await.succeeded(); - - let (value, _) = batman_index - .update_settings(json!({ - "sortableAttributes": ["title"], - "filterableAttributes": ["title"], - "rankingRules": [ - "sort", - "words", - "typo", - "proximity", - "attribute", - "exactness" - ] - })) - .await; - batman_index.wait_task(value.uid()).await.succeeded(); + let batman_index = shared_batman_index().await; // without merging, it works let (response, code) = server From 2269104337b6d38e7b1d25ab5b84cfa6f5c5c289 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Sat, 14 Jun 2025 13:35:03 +0300 Subject: [PATCH 14/17] Use unique_index_with_prefix() instead of composing the index names manually with Uuid Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 8c6e45c74..8ddcb2cdc 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -1,6 +1,5 @@ use meili_snap::{json_string, snapshot}; use tokio::sync::OnceCell; -use uuid::Uuid; use super::{DOCUMENTS, FRUITS_DOCUMENTS, NESTED_DOCUMENTS}; use crate::common::index::Index; @@ -849,13 +848,13 @@ async fn federation_one_index_doesnt_exist() { async fn search_multiple_indexes_dont_exist() { let server = Server::new_shared(); - let index_1 = format!("index_1-{}", Uuid::new_v4()); - let index_2 = format!("index_2-{}", Uuid::new_v4()); + let index_1 = server.unique_index_with_prefix("index_1"); + let index_2 = server.unique_index_with_prefix("index_2"); let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : index_1, "q": "glass"}, - {"indexUid": index_2, "q": "pésti"}, + {"indexUid" : index_1.uid, "q": "glass"}, + {"indexUid": index_2.uid, "q": "pésti"}, ]})) .await; snapshot!(code, @"400 Bad Request"); @@ -873,13 +872,13 @@ async fn search_multiple_indexes_dont_exist() { async fn federation_multiple_indexes_dont_exist() { let server = Server::new_shared(); - let index_1 = format!("index_1-{}", Uuid::new_v4()); - let index_2 = format!("index_2-{}", Uuid::new_v4()); + let index_1 = server.unique_index_with_prefix("index_1"); + let index_2 = server.unique_index_with_prefix("index_2"); let (response, code) = server .multi_search(json!({"federation": {}, "queries": [ - {"indexUid" : index_1, "q": "glass"}, - {"indexUid": index_2, "q": "pésti"}, + {"indexUid" : index_1.uid, "q": "glass"}, + {"indexUid": index_2.uid, "q": "pésti"}, ]})) .await; snapshot!(code, @"400 Bad Request"); From 059832025231ae2ce399ee85e36e13cf1d65b67a Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Sat, 14 Jun 2025 14:07:57 +0300 Subject: [PATCH 15/17] Try to debug the problem with the existing "test" index in a shared server Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index 8ddcb2cdc..f136fd4eb 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -848,19 +848,20 @@ async fn federation_one_index_doesnt_exist() { async fn search_multiple_indexes_dont_exist() { let server = Server::new_shared(); - let index_1 = server.unique_index_with_prefix("index_1"); - let index_2 = server.unique_index_with_prefix("index_2"); - let (response, code) = server .multi_search(json!({"queries": [ - {"indexUid" : index_1.uid, "q": "glass"}, - {"indexUid": index_2.uid, "q": "pésti"}, + {"indexUid" : "test", "q": "glass"}, + {"indexUid": "nested", "q": "pésti"}, ]})) .await; snapshot!(code, @"400 Bad Request"); + + let (list_response, _code) = server.list_indexes(Some(0), Some(1_000_000)).await; + dbg!(list_response); + snapshot!(json_string!(response), @r###" { - "message": "Inside `.queries[0]`: Index `index_1-[uuid]` not found.", + "message": "Inside `.queries[0]`: Index `test` not found.", "code": "index_not_found", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#index_not_found" From 95e8a9bef1f5718e8332b4fc10e3b83c4c7ea97c Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Sat, 14 Jun 2025 15:10:48 +0300 Subject: [PATCH 16/17] Use a unique name for an index in a shared server Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/index/create_index.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/meilisearch/tests/index/create_index.rs b/crates/meilisearch/tests/index/create_index.rs index e8efd14e2..3422e8b3f 100644 --- a/crates/meilisearch/tests/index/create_index.rs +++ b/crates/meilisearch/tests/index/create_index.rs @@ -46,8 +46,10 @@ async fn create_index_with_gzip_encoded_request_and_receiving_brotli_encoded_res let server = Server::new_shared(); let app = server.init_web_app().await; + let index = server.unique_index_with_prefix("test"); + let body = serde_json::to_string(&json!({ - "uid": "test", + "uid": index.uid.clone(), "primaryKey": None::<&str>, })) .unwrap(); @@ -68,7 +70,7 @@ async fn create_index_with_gzip_encoded_request_and_receiving_brotli_encoded_res let parsed_response = serde_json::from_slice::(decoded.into().as_ref()).expect("Expecting valid json"); - assert_eq!(parsed_response["indexUid"], "test"); + assert_eq!(parsed_response["indexUid"], index.uid); } #[actix_rt::test] From 6ee608c2d1b5ffef23118af8972dd0bf38aa8f83 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Sat, 14 Jun 2025 15:45:04 +0300 Subject: [PATCH 17/17] Remove debug leftovers Signed-off-by: Martin Tzvetanov Grigorov --- crates/meilisearch/tests/search/multi/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/meilisearch/tests/search/multi/mod.rs b/crates/meilisearch/tests/search/multi/mod.rs index f136fd4eb..cf98baa10 100644 --- a/crates/meilisearch/tests/search/multi/mod.rs +++ b/crates/meilisearch/tests/search/multi/mod.rs @@ -855,10 +855,6 @@ async fn search_multiple_indexes_dont_exist() { ]})) .await; snapshot!(code, @"400 Bad Request"); - - let (list_response, _code) = server.list_indexes(Some(0), Some(1_000_000)).await; - dbg!(list_response); - snapshot!(json_string!(response), @r###" { "message": "Inside `.queries[0]`: Index `test` not found.",