|
| 1 | +--- |
| 2 | +title: Network — Meilisearch API reference |
| 3 | +description: Use the `/network` route to create a network of Meilisearch instances. |
| 4 | +--- |
| 5 | + |
| 6 | +# Network <NoticeTag type="experimental" label="experimental" /> |
| 7 | + |
| 8 | +Use the `/network` route to create a network of Meilisearch instances. This is particularly useful when used together with federated search to implement horizontal database partition strategies such as sharding. |
| 9 | + |
| 10 | +<Capsule intent="note" title="Activating `/metrics`"> |
| 11 | +This is an experimental feature. Use the experimental features endpoint to activate it: |
| 12 | + |
| 13 | +```sh |
| 14 | +curl \ |
| 15 | + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ |
| 16 | + -H 'Content-Type: application/json' \ |
| 17 | + --data-binary '{ |
| 18 | + "network": true |
| 19 | + }' |
| 20 | +``` |
| 21 | + |
| 22 | +This feature is not available for Meilisearch Cloud users. |
| 23 | +</Capsule> |
| 24 | + |
| 25 | +## The network object |
| 26 | + |
| 27 | +```json |
| 28 | +{ |
| 29 | + "self": "ms-00", |
| 30 | + "remotes": { |
| 31 | + "ms-00": { |
| 32 | + "url": "http://ms-1235.example.meilisearch.io", |
| 33 | + "searchApiKey": "Ecd1SDDi4pqdJD6qYLxD3y7VZAEb4d9j6LJgt4d6xas" |
| 34 | + }, |
| 35 | + "ms-01": { |
| 36 | + "url": "http://ms-4242.example.meilisearch.io", |
| 37 | + "searchApiKey": "hrVu-OMcjPGElK7692K7bwriBoGyHXTMvB5NmZkMKqQ" |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +### `self` |
| 44 | + |
| 45 | +**Type**: String<br /> |
| 46 | +**Default value**: `null`<br /> |
| 47 | +**Description**: A string indicating the name of the current instance |
| 48 | + |
| 49 | +### `remotes` |
| 50 | + |
| 51 | +**Type**: Object<br /> |
| 52 | +**Default value**: `{}`<br /> |
| 53 | +**Description**: An object containing `remote` objects. The key of each remote object indicates the name of the remote instance |
| 54 | + |
| 55 | +### The remote object |
| 56 | + |
| 57 | +```json |
| 58 | +"ms-00": { |
| 59 | + "url": "http://ms-1235.example.meilisearch.io", |
| 60 | + "searchApiKey": "Ecd1SDDi4pqdJD6qYLxD3y7VZAEb4d9j6LJgt4d6xas" |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +### `url` |
| 65 | + |
| 66 | +**Type**: String<br /> |
| 67 | +**Default value**: `null`<br /> |
| 68 | +**Description**: URL indicating the address of a Meilisearch instance. This URL does not need to be public, but must be accessible to all instances in the network. Required. |
| 69 | + |
| 70 | +### `searchApiKey` |
| 71 | + |
| 72 | +**Type**: Stringf<br /> |
| 73 | +**Default value**: `null`<br /> |
| 74 | +**Description**: An API key with search permissions |
| 75 | + |
| 76 | +## Get the network object |
| 77 | + |
| 78 | +<RouteHighlighter method="GET" route="/network"/> |
| 79 | + |
| 80 | +Returns the current value of the instance's network object. |
| 81 | + |
| 82 | +### Example |
| 83 | + |
| 84 | +<CodeSamples id="get_network_1" /> |
| 85 | + |
| 86 | +#### Response: `200 Ok` |
| 87 | + |
| 88 | +```json |
| 89 | +{ |
| 90 | + "self": "ms-00", |
| 91 | + "remotes": { |
| 92 | + "ms-00": { |
| 93 | + "url": "http://ms-1235.example.meilisearch.io", |
| 94 | + "searchApiKey": "Ecd1SDDi4pqdJD6qYLxD3y7VZAEb4d9j6LJgt4d6xas" |
| 95 | + }, |
| 96 | + "ms-01": { |
| 97 | + "url": "http://ms-4242.example.meilisearch.io", |
| 98 | + "searchApiKey": "hrVu-OMcjPGElK7692K7bwriBoGyHXTMvB5NmZkMKqQ" |
| 99 | + } |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +## Update the network object |
| 105 | + |
| 106 | +<RouteHighlighter method="PATCH" route="/network"/> |
| 107 | + |
| 108 | +Update the `self` and `remotes` fields of the network object. |
| 109 | + |
| 110 | +Updates to the network object are **partial**. Only provide the fields you intend to update. Fields not present in the payload will remain unchanged. |
| 111 | + |
| 112 | +To reset `self` and `remotes` to their original value, set them to `null`. To remov a single `remote` from your network, set the value of its name to `null`. |
| 113 | + |
| 114 | +### Body |
| 115 | + |
| 116 | +| Name | Type | Default value | Description | |
| 117 | +| :-------------------------------- | :----- | :------------ | :---------------------------------- | |
| 118 | +| **[`self`](#self)** | String | `null` | The name of the current instance | |
| 119 | +| **[`remotes`](#remotes)** | String | `null` | A list of remote objects describing accessible Meilisearch instances | |
| 120 | + |
| 121 | +### Example |
| 122 | + |
| 123 | +<CodeSamples id="update_network_1" /> |
| 124 | + |
| 125 | +#### Response: `200 Ok` |
| 126 | + |
| 127 | +```json |
| 128 | + |
| 129 | +``` |
| 130 | + |
0 commit comments