More assertion fixes

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
Martin Tzvetanov Grigorov 2025-06-11 08:42:35 +03:00
parent 8a916a4e42
commit 0263eb0aec
No known key found for this signature in database
GPG Key ID: 3194FD8C1AE300EF

View File

@ -181,7 +181,7 @@ async fn federation_single_search_single_index() {
#[actix_rt::test] #[actix_rt::test]
async fn federation_multiple_search_single_index() { async fn federation_multiple_search_single_index() {
let server = Server::new_shared(); let server = Server::new_shared();
let index = shared_index_with_documents().await; let index = shared_index_with_score_documents().await;
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
@ -199,7 +199,7 @@ async fn federation_multiple_search_single_index() {
"title": "Batman", "title": "Batman",
"id": "D", "id": "D",
"_federation": { "_federation": {
"indexUid": "SHARED_DOCUMENTS", "indexUid": "SHARED_SCORE_DOCUMENTS",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -208,7 +208,7 @@ async fn federation_multiple_search_single_index() {
"title": "Batman Returns", "title": "Batman Returns",
"id": "C", "id": "C",
"_federation": { "_federation": {
"indexUid": "SHARED_DOCUMENTS", "indexUid": "SHARED_SCORE_DOCUMENTS",
"queriesPosition": 3, "queriesPosition": 3,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -217,7 +217,7 @@ async fn federation_multiple_search_single_index() {
"title": "Batman the dark knight returns: Part 1", "title": "Batman the dark knight returns: Part 1",
"id": "A", "id": "A",
"_federation": { "_federation": {
"indexUid": "SHARED_DOCUMENTS", "indexUid": "SHARED_SCORE_DOCUMENTS",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 0.9848484848484848 "weightedRankingScore": 0.9848484848484848
} }
@ -226,7 +226,7 @@ async fn federation_multiple_search_single_index() {
"title": "Batman the dark knight returns: Part 2", "title": "Batman the dark knight returns: Part 2",
"id": "B", "id": "B",
"_federation": { "_federation": {
"indexUid": "SHARED_DOCUMENTS", "indexUid": "SHARED_SCORE_DOCUMENTS",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 0.9848484848484848 "weightedRankingScore": 0.9848484848484848
} }
@ -235,7 +235,7 @@ async fn federation_multiple_search_single_index() {
"title": "Badman", "title": "Badman",
"id": "E", "id": "E",
"_federation": { "_federation": {
"indexUid": "SHARED_DOCUMENTS", "indexUid": "SHARED_SCORE_DOCUMENTS",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.5 "weightedRankingScore": 0.5
} }
@ -880,14 +880,13 @@ async fn federation_one_query_sort_error() {
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
{"indexUid" : index.uid, "q": "glass"}, {"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; .await;
dbg!(&response);
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" 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", "code": "invalid_search_sort",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_search_sort" "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"]}, {"indexUid" : score_index.uid, "q": "batman returns", "attributesToRetrieve": ["title"]},
]})) ]}))
.await; .await;
dbg!(&response);
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###" snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]", ".**._rankingScore" => "[score]" }), @r###"
{ {
@ -4324,7 +4322,7 @@ async fn federation_facets_different_indexes_same_facet() {
.await; .await;
batman_index.wait_task(value.uid()).await.succeeded(); 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 documents = SCORE_DOCUMENTS.clone();
let (value, _) = batman_2_index.add_documents(documents, None).await; let (value, _) = batman_2_index.add_documents(documents, None).await;
@ -4375,7 +4373,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Badman", "title": "Badman",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4391,7 +4389,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman", "title": "Batman",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4407,7 +4405,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman Returns", "title": "Batman Returns",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4423,7 +4421,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman the dark knight returns: Part 1", "title": "Batman the dark knight returns: Part 1",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4439,7 +4437,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman the dark knight returns: Part 2", "title": "Batman the dark knight returns: Part 2",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4490,7 +4488,7 @@ async fn federation_facets_different_indexes_same_facet() {
"offset": 0, "offset": 0,
"estimatedTotalHits": 15, "estimatedTotalHits": 15,
"facetsByIndex": { "facetsByIndex": {
"batman-2-[uuid]": { "batman-[uuid]": {
"distribution": { "distribution": {
"title": { "title": {
"Badman": 1, "Badman": 1,
@ -4502,7 +4500,7 @@ async fn federation_facets_different_indexes_same_facet() {
}, },
"stats": {} "stats": {}
}, },
"batman-[uuid]": { "batman_2-[uuid]": {
"distribution": { "distribution": {
"title": { "title": {
"Badman": 1, "Badman": 1,
@ -4565,7 +4563,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Badman", "title": "Badman",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4581,7 +4579,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman", "title": "Batman",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4597,7 +4595,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman Returns", "title": "Batman Returns",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4613,7 +4611,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman the dark knight returns: Part 1", "title": "Batman the dark knight returns: Part 1",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4629,7 +4627,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman the dark knight returns: Part 2", "title": "Batman the dark knight returns: Part 2",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -4735,7 +4733,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman the dark knight returns: Part 2", "title": "Batman the dark knight returns: Part 2",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.7028218694885362 "weightedRankingScore": 0.7028218694885362
} }
@ -4751,7 +4749,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman the dark knight returns: Part 1", "title": "Batman the dark knight returns: Part 1",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.7028218694885362 "weightedRankingScore": 0.7028218694885362
} }
@ -4767,7 +4765,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman Returns", "title": "Batman Returns",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.8317901234567902 "weightedRankingScore": 0.8317901234567902
} }
@ -4783,7 +4781,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Batman", "title": "Batman",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.23106060606060605 "weightedRankingScore": 0.23106060606060605
} }
@ -4799,7 +4797,7 @@ async fn federation_facets_different_indexes_same_facet() {
{ {
"title": "Badman", "title": "Badman",
"_federation": { "_federation": {
"indexUid": "batman-2-[uuid]", "indexUid": "batman_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.5 "weightedRankingScore": 0.5
} }
@ -4810,7 +4808,7 @@ async fn federation_facets_different_indexes_same_facet() {
"offset": 0, "offset": 0,
"estimatedTotalHits": 11, "estimatedTotalHits": 11,
"facetsByIndex": { "facetsByIndex": {
"batman-2-[uuid]": { "batman-[uuid]": {
"distribution": { "distribution": {
"title": { "title": {
"Badman": 1, "Badman": 1,
@ -4822,7 +4820,7 @@ async fn federation_facets_different_indexes_same_facet() {
}, },
"stats": {} "stats": {}
}, },
"batman-[uuid]": { "batman_2-[uuid]": {
"distribution": { "distribution": {
"title": { "title": {
"Badman": 1, "Badman": 1,
@ -4868,7 +4866,7 @@ async fn federation_facets_same_indexes() {
.await; .await;
doggos_index.wait_task(value.uid()).await.succeeded(); 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 documents = NESTED_DOCUMENTS.clone();
let (value, _) = doggos2_index.add_documents(documents, None).await; let (value, _) = doggos2_index.add_documents(documents, None).await;
@ -4996,7 +4994,7 @@ async fn federation_facets_same_indexes() {
{ {
"id": 852, "id": 852,
"_federation": { "_federation": {
"indexUid": "doggos-2-[uuid]", "indexUid": "doggos_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.9621212121212122 "weightedRankingScore": 0.9621212121212122
} }
@ -5004,7 +5002,7 @@ async fn federation_facets_same_indexes() {
{ {
"id": 750, "id": 750,
"_federation": { "_federation": {
"indexUid": "doggos-2-[uuid]", "indexUid": "doggos_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.9621212121212122 "weightedRankingScore": 0.9621212121212122
} }
@ -5015,27 +5013,6 @@ async fn federation_facets_same_indexes() {
"offset": 0, "offset": 0,
"estimatedTotalHits": 4, "estimatedTotalHits": 4,
"facetsByIndex": { "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]": { "doggos-[uuid]": {
"distribution": { "distribution": {
"doggos.age": { "doggos.age": {
@ -5059,6 +5036,27 @@ async fn federation_facets_same_indexes() {
"max": 6.0 "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, "id": 852,
"_federation": { "_federation": {
"indexUid": "doggos-2-[uuid]", "indexUid": "doggos_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.9621212121212122 "weightedRankingScore": 0.9621212121212122
} }
@ -5107,7 +5105,7 @@ async fn federation_facets_same_indexes() {
{ {
"id": 750, "id": 750,
"_federation": { "_federation": {
"indexUid": "doggos-2-[uuid]", "indexUid": "doggos_2-[uuid]",
"queriesPosition": 1, "queriesPosition": 1,
"weightedRankingScore": 0.9621212121212122 "weightedRankingScore": 0.9621212121212122
} }
@ -5170,7 +5168,7 @@ async fn federation_inconsistent_merge_order() {
.await; .await;
movies_index.wait_task(value.uid()).await.succeeded(); 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 documents = DOCUMENTS.clone();
let (value, _) = movies2_index.add_documents(documents, None).await; let (value, _) = movies2_index.add_documents(documents, None).await;
@ -5286,7 +5284,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Captain Marvel", "title": "Captain Marvel",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5302,7 +5300,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Escape Room", "title": "Escape Room",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5318,7 +5316,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Gläss", "title": "Gläss",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5334,7 +5332,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "How to Train Your Dragon: The Hidden World", "title": "How to Train Your Dragon: The Hidden World",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5350,7 +5348,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Shazam!", "title": "Shazam!",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5373,13 +5371,13 @@ async fn federation_inconsistent_merge_order() {
}, },
"stats": {} "stats": {}
}, },
"movies-2-[uuid]": { "movies-[uuid]": {
"distribution": { "distribution": {
"color": { "color": {
"red": 3,
"blue": 3, "blue": 3,
"yellow": 2, "green": 2,
"green": 2 "red": 3,
"yellow": 2
}, },
"title": { "title": {
"Captain Marvel": 1, "Captain Marvel": 1,
@ -5391,13 +5389,13 @@ async fn federation_inconsistent_merge_order() {
}, },
"stats": {} "stats": {}
}, },
"movies-[uuid]": { "movies_2-[uuid]": {
"distribution": { "distribution": {
"color": { "color": {
"blue": 3,
"green": 2,
"red": 3, "red": 3,
"yellow": 2 "blue": 3,
"yellow": 2,
"green": 2
}, },
"title": { "title": {
"Captain Marvel": 1, "Captain Marvel": 1,
@ -5431,7 +5429,7 @@ async fn federation_inconsistent_merge_order() {
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" 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", "code": "invalid_multi_search_facet_order",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_multi_search_facet_order" "link": "https://docs.meilisearch.com/errors#invalid_multi_search_facet_order"
@ -5456,7 +5454,7 @@ async fn federation_inconsistent_merge_order() {
]})) ]}))
.await; .await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
snapshot!(json_string!(response), @r###" snapshot!(json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###"
{ {
"hits": [ "hits": [
{ {
@ -5510,7 +5508,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Captain Marvel", "title": "Captain Marvel",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5526,7 +5524,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Escape Room", "title": "Escape Room",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5542,7 +5540,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Gläss", "title": "Gläss",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5558,7 +5556,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "How to Train Your Dragon: The Hidden World", "title": "How to Train Your Dragon: The Hidden World",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }
@ -5574,7 +5572,7 @@ async fn federation_inconsistent_merge_order() {
{ {
"title": "Shazam!", "title": "Shazam!",
"_federation": { "_federation": {
"indexUid": "movies-2-[uuid]", "indexUid": "movies_2-[uuid]",
"queriesPosition": 2, "queriesPosition": 2,
"weightedRankingScore": 1.0 "weightedRankingScore": 1.0
} }