|
1 | 1 | import pytest |
2 | 2 |
|
3 | 3 | from meilisearch.errors import MeilisearchApiError |
4 | | -from tests.common import INDEX_UID |
| 4 | +from tests.common import INDEX_UID, REMOTE_MS_1, REMOTE_MS_2 |
5 | 5 |
|
6 | 6 |
|
7 | 7 | def test_basic_multi_search(client, empty_index): |
@@ -75,3 +75,36 @@ def test_multi_search_with_federation_options(client, index_with_documents): |
75 | 75 | assert response["hits"][0]["_federation"]["weightedRankingScore"] >= 0.99 |
76 | 76 | assert response["limit"] == 2 |
77 | 77 | assert response["offset"] == 0 |
| 78 | + |
| 79 | + |
| 80 | +@pytest.mark.usefixtures("enable_network_options") |
| 81 | +def test_multi_search_with_network(client, index_with_documents): |
| 82 | + """Tests multi-search with network, with federation options.""" |
| 83 | + index_with_documents() |
| 84 | + resp = client.add_or_update_networks( |
| 85 | + { |
| 86 | + "self": REMOTE_MS_1, |
| 87 | + "remotes": { |
| 88 | + REMOTE_MS_1: { |
| 89 | + "url": "http://ms-1235.example.meilisearch.io", |
| 90 | + "searchApiKey": "xxxxxxxx", |
| 91 | + }, |
| 92 | + REMOTE_MS_2: { |
| 93 | + "url": "http://ms-1255.example.meilisearch.io", |
| 94 | + "searchApiKey": "xxxxxxxx", |
| 95 | + }, |
| 96 | + }, |
| 97 | + } |
| 98 | + ) |
| 99 | + response = client.multi_search( |
| 100 | + [{"indexUid": INDEX_UID, "q": "", "federationOptions": {"remote": REMOTE_MS_1}}], |
| 101 | + federation={}, |
| 102 | + ) |
| 103 | + |
| 104 | + assert "results" not in resp |
| 105 | + assert "results" not in response |
| 106 | + assert isinstance(response["hits"], list) |
| 107 | + assert len(response["hits"]) >= 0 |
| 108 | + assert response["hits"][0]["_federation"]["indexUid"] == INDEX_UID |
| 109 | + assert response["hits"][0]["_federation"]["remote"] == REMOTE_MS_1 |
| 110 | + assert response["remoteErrors"] == {} |
0 commit comments