From c42746c4cd79349122d29095d5df0d378966aa59 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 17 Sep 2024 17:22:14 +0200 Subject: [PATCH] Update tests --- meilisearch/tests/search/multi.rs | 512 +----------------------------- 1 file changed, 4 insertions(+), 508 deletions(-) diff --git a/meilisearch/tests/search/multi.rs b/meilisearch/tests/search/multi.rs index 662d10a4c..7cf4bd415 100644 --- a/meilisearch/tests/search/multi.rs +++ b/meilisearch/tests/search/multi.rs @@ -5804,356 +5804,15 @@ async fn federation_inconsistent_merge_order() { } "###); - // works again with merging and forcing an order - let (response, code) = server -.multi_search(json!({"federation": { - "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "movies-2": ["title", "color"], - }, - "mergeFacets": { - "sortFacetValuesBy": "count" - } -}, "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"] }, -]})) -.await; - snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" - { - "hits": [ - { - "title": "Badman", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman Returns", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman the dark knight returns: Part 1", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman the dark knight returns: Part 2", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Captain Marvel", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Captain Marvel", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Escape Room", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Escape Room", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Gläss", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Gläss", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "How to Train Your Dragon: The Hidden World", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "How to Train Your Dragon: The Hidden World", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Shazam!", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Shazam!", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - } - ], - "processingTimeMs": "[time]", - "limit": 20, - "offset": 0, - "estimatedTotalHits": 15, - "facetDistribution": { - "color": { - "red": 6, - "blue": 6, - "yellow": 4, - "green": 4 - }, - "title": { - "Shazam!": 2, - "How to Train Your Dragon: The Hidden World": 2, - "Gläss": 2, - "Escape Room": 2, - "Captain Marvel": 2, - "Batman the dark knight returns: Part 2": 1, - "Batman the dark knight returns: Part 1": 1, - "Batman Returns": 1, - "Batman": 1, - "Badman": 1 - } - }, - "facetStats": {} - } - "###); - - // works also with the other order - let (response, code) = server - .multi_search(json!({"federation": { - "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "movies-2": ["title", "color"], - }, - "mergeFacets": { - "sortFacetValuesBy": "alpha" - } - }, "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"] }, - ]})) - .await; - snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" - { - "hits": [ - { - "title": "Badman", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman Returns", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman the dark knight returns: Part 1", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman the dark knight returns: Part 2", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Captain Marvel", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Captain Marvel", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Escape Room", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Escape Room", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Gläss", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Gläss", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "How to Train Your Dragon: The Hidden World", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "How to Train Your Dragon: The Hidden World", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Shazam!", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Shazam!", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - } - ], - "processingTimeMs": "[time]", - "limit": 20, - "offset": 0, - "estimatedTotalHits": 15, - "facetDistribution": { - "color": { - "blue": 6, - "green": 4, - "red": 6, - "yellow": 4 - }, - "title": { - "Badman": 1, - "Batman": 1, - "Batman Returns": 1, - "Batman the dark knight returns: Part 1": 1, - "Batman the dark knight returns: Part 2": 1, - "Captain Marvel": 2, - "Escape Room": 2, - "Gläss": 2, - "How to Train Your Dragon: The Hidden World": 2, - "Shazam!": 2 - } - }, - "facetStats": {} - } - "###); - // can limit the number of values let (response, code) = server .multi_search(json!({"federation": { "facetsByIndex": { "movies": ["title", "color"], "batman": ["title"], - "movies-2": ["title", "color"], + "movies-2": ["title"], }, "mergeFacets": { - "sortFacetValuesBy": "count", "maxValuesPerFacet": 3, } }, "queries": [ @@ -6293,172 +5952,9 @@ async fn federation_inconsistent_merge_order() { "estimatedTotalHits": 15, "facetDistribution": { "color": { - "red": 6, - "blue": 6, - "yellow": 4 - }, - "title": { - "Shazam!": 2, - "How to Train Your Dragon: The Hidden World": 2, - "Gläss": 2 - } - }, - "facetStats": {} - } - "###); - - // can limit the number of values by alpha - let (response, code) = server - .multi_search(json!({"federation": { - "facetsByIndex": { - "movies": ["title", "color"], - "batman": ["title"], - "movies-2": ["title", "color"], - }, - "mergeFacets": { - "sortFacetValuesBy": "alpha", - "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"] }, - ]})) - .await; - snapshot!(code, @"200 OK"); - insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###" - { - "hits": [ - { - "title": "Badman", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman Returns", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman the dark knight returns: Part 1", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Batman the dark knight returns: Part 2", - "_federation": { - "indexUid": "batman", - "queriesPosition": 1, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Captain Marvel", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Captain Marvel", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Escape Room", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Escape Room", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Gläss", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Gläss", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "How to Train Your Dragon: The Hidden World", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "How to Train Your Dragon: The Hidden World", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Shazam!", - "_federation": { - "indexUid": "movies", - "queriesPosition": 0, - "weightedRankingScore": 1.0 - } - }, - { - "title": "Shazam!", - "_federation": { - "indexUid": "movies-2", - "queriesPosition": 2, - "weightedRankingScore": 1.0 - } - } - ], - "processingTimeMs": "[time]", - "limit": 20, - "offset": 0, - "estimatedTotalHits": 15, - "facetDistribution": { - "color": { - "blue": 6, - "green": 4, - "red": 6 + "blue": 3, + "green": 2, + "red": 3 }, "title": { "Badman": 1,