curl \
-X PATCH 'MEILISEARCH_URL/network' \
-H 'Content-Type: application/json' \
--data-binary '{
"self": "ms-00",
"remotes": {
"ms-00": {
"url": "http://INSTANCE_URL",
"searchApiKey": "INSTANCE_API_KEY"
},
"ms-01": {
"url": "http://ANOTHER_INSTANCE_URL",
"searchApiKey": "ANOTHER_INSTANCE_API_KEY"
}
}
}'import requests
url = "http://localhost:7700/network"
payload = {
"remotes": {
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
},
"shards": { "shard-00": { "remotes": ["ms-00", "ms-01"] } },
"previousShards": { "shard-00": { "remotes": ["ms-00", "ms-01"] } },
"self": "ms-00",
"leader": "ms-00",
"previousRemotes": {
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
remotes: {
'ms-00': {url: 'http://localhost:7700'},
'ms-01': {url: 'http://localhost:7701'}
},
shards: {'shard-00': {remotes: ['ms-00', 'ms-01']}},
previousShards: {'shard-00': {remotes: ['ms-00', 'ms-01']}},
self: 'ms-00',
leader: 'ms-00',
previousRemotes: {
'ms-00': {url: 'http://localhost:7700'},
'ms-01': {url: 'http://localhost:7701'}
}
})
};
fetch('http://localhost:7700/network', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "7700",
CURLOPT_URL => "http://localhost:7700/network",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'remotes' => [
'ms-00' => [
'url' => 'http://localhost:7700'
],
'ms-01' => [
'url' => 'http://localhost:7701'
]
],
'shards' => [
'shard-00' => [
'remotes' => [
'ms-00',
'ms-01'
]
]
],
'previousShards' => [
'shard-00' => [
'remotes' => [
'ms-00',
'ms-01'
]
]
],
'self' => 'ms-00',
'leader' => 'ms-00',
'previousRemotes' => [
'ms-00' => [
'url' => 'http://localhost:7700'
],
'ms-01' => [
'url' => 'http://localhost:7701'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:7700/network"
payload := strings.NewReader("{\n \"remotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n },\n \"shards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"previousShards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"self\": \"ms-00\",\n \"leader\": \"ms-00\",\n \"previousRemotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("http://localhost:7700/network")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"remotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n },\n \"shards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"previousShards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"self\": \"ms-00\",\n \"leader\": \"ms-00\",\n \"previousRemotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:7700/network")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"remotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n },\n \"shards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"previousShards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"self\": \"ms-00\",\n \"leader\": \"ms-00\",\n \"previousRemotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"self": "ms-0",
"remotes": {
"ms-0": {
"url": "http://localhost:7700",
"searchApiKey": null,
"writeApiKey": null
},
"ms-1": {
"url": "http://localhost:7701",
"searchApiKey": "foo",
"writeApiKey": "bar"
},
"ms-2": {
"url": "http://localhost:7702",
"searchApiKey": "bar",
"writeApiKey": "foo"
}
}
}{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}Configure network topology
Add or remove remote nodes from the network. Changes apply to the current instance’s view of the cluster.
curl \
-X PATCH 'MEILISEARCH_URL/network' \
-H 'Content-Type: application/json' \
--data-binary '{
"self": "ms-00",
"remotes": {
"ms-00": {
"url": "http://INSTANCE_URL",
"searchApiKey": "INSTANCE_API_KEY"
},
"ms-01": {
"url": "http://ANOTHER_INSTANCE_URL",
"searchApiKey": "ANOTHER_INSTANCE_API_KEY"
}
}
}'import requests
url = "http://localhost:7700/network"
payload = {
"remotes": {
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
},
"shards": { "shard-00": { "remotes": ["ms-00", "ms-01"] } },
"previousShards": { "shard-00": { "remotes": ["ms-00", "ms-01"] } },
"self": "ms-00",
"leader": "ms-00",
"previousRemotes": {
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
remotes: {
'ms-00': {url: 'http://localhost:7700'},
'ms-01': {url: 'http://localhost:7701'}
},
shards: {'shard-00': {remotes: ['ms-00', 'ms-01']}},
previousShards: {'shard-00': {remotes: ['ms-00', 'ms-01']}},
self: 'ms-00',
leader: 'ms-00',
previousRemotes: {
'ms-00': {url: 'http://localhost:7700'},
'ms-01': {url: 'http://localhost:7701'}
}
})
};
fetch('http://localhost:7700/network', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "7700",
CURLOPT_URL => "http://localhost:7700/network",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'remotes' => [
'ms-00' => [
'url' => 'http://localhost:7700'
],
'ms-01' => [
'url' => 'http://localhost:7701'
]
],
'shards' => [
'shard-00' => [
'remotes' => [
'ms-00',
'ms-01'
]
]
],
'previousShards' => [
'shard-00' => [
'remotes' => [
'ms-00',
'ms-01'
]
]
],
'self' => 'ms-00',
'leader' => 'ms-00',
'previousRemotes' => [
'ms-00' => [
'url' => 'http://localhost:7700'
],
'ms-01' => [
'url' => 'http://localhost:7701'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:7700/network"
payload := strings.NewReader("{\n \"remotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n },\n \"shards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"previousShards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"self\": \"ms-00\",\n \"leader\": \"ms-00\",\n \"previousRemotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("http://localhost:7700/network")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"remotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n },\n \"shards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"previousShards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"self\": \"ms-00\",\n \"leader\": \"ms-00\",\n \"previousRemotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:7700/network")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"remotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n },\n \"shards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"previousShards\": {\n \"shard-00\": {\n \"remotes\": [\n \"ms-00\",\n \"ms-01\"\n ]\n }\n },\n \"self\": \"ms-00\",\n \"leader\": \"ms-00\",\n \"previousRemotes\": {\n \"ms-00\": {\n \"url\": \"http://localhost:7700\"\n },\n \"ms-01\": {\n \"url\": \"http://localhost:7701\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"self": "ms-0",
"remotes": {
"ms-0": {
"url": "http://localhost:7700",
"searchApiKey": null,
"writeApiKey": null
},
"ms-1": {
"url": "http://localhost:7701",
"searchApiKey": "foo",
"writeApiKey": "bar"
},
"ms-2": {
"url": "http://localhost:7702",
"searchApiKey": "bar",
"writeApiKey": "foo"
}
}
}{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}Authorizations
An API key is a token that you provide when making API calls. Read more about how to secure your project.
Include the API key to the Authorization header, for instance:
-H 'Authorization: Bearer 6436fc5237b0d6e0d64253fbaac21d135012ecf1'
If you use a SDK, ensure you instantiate the client with the API key, for instance with JS SDK:
const client = new MeiliSearch({
host: 'MEILISEARCH_URL',
apiKey: '6436fc5237b0d6e0d64253fbaac21d135012ecf1'
});
Body
Network topology configuration for distributed Meilisearch
Map of remote instance names to their configurations
- Pass
nullas a value for a remote to remove it from the configuration. - Removing a remote will also remove it from all shards.
- Remotes that don't appear in this list will be unmodified by the network call.
Show child attributes
Show child attributes
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
Map of shard names to their configurations.
- Pass
nullas a value for a shard to remove it from the configuration. - Shards that don't appear in this list will be unmodified by the network call.
Show child attributes
Show child attributes
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
Previous shard configurations
This field should not be passed by end-users. It is used in internal communications between Meilisearch instances
Show child attributes
Show child attributes
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
Name of this instance in the network
"ms-00"
Name of the leader instance in the network
"ms-00"
Previous remote configurations
This field should not be passed by end-users. It is used in internal communications between Meilisearch instances
Show child attributes
Show child attributes
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
Response
New network state is returned.
Network topology configuration for distributed Meilisearch
Map of remote instance names to their configurations
- Pass
nullas a value for a remote to remove it from the configuration. - Removing a remote will also remove it from all shards.
- Remotes that don't appear in this list will be unmodified by the network call.
Show child attributes
Show child attributes
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
Map of shard names to their configurations.
- Pass
nullas a value for a shard to remove it from the configuration. - Shards that don't appear in this list will be unmodified by the network call.
Show child attributes
Show child attributes
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
Previous shard configurations
This field should not be passed by end-users. It is used in internal communications between Meilisearch instances
Show child attributes
Show child attributes
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
Name of this instance in the network
"ms-00"
Name of the leader instance in the network
"ms-00"
Previous remote configurations
This field should not be passed by end-users. It is used in internal communications between Meilisearch instances
Show child attributes
Show child attributes
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
Was this page helpful?