Skip to main content
PATCH
/
network
cURL
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"
      }
    }
  }'
client.initializeNetwork({
self: 'https://instance1.meilisearch.com',
remotes: {
instance2: {
url: 'https://instance2.meilisearch.com',
searchApiKey: 'SEARCH_API_KEY',
writeApiKey: 'WRITE_API_KEY'
}
}
})
$client->updateNetwork([
'self' => 'ms-00',
'leader' => 'ms-00',
'remotes' => [
'ms-00' => [
'url' => 'http://INSTANCE_URL',
'searchApiKey' => 'INSTANCE_API_KEY',
'writeApiKey' => 'INSTANCE_WRITE_API_KEY'
],
'ms-01' => [
'url' => 'http://ANOTHER_INSTANCE_URL',
'searchApiKey' => 'ANOTHER_INSTANCE_API_KEY',
'writeApiKey' => 'ANOTHER_INSTANCE_WRITE_API_KEY'
]
]
]);
client.add_or_update_networks({
"remotes": {
"MEILISEARCH_URL": {
"searchApiKey": "masterKey"
}
},
"leader": None
})
client.UpdateNetwork(&meilisearch.UpdateNetworkRequest{
Self: meilisearch.String("ms-00"),
Leader: meilisearch.String("ms-00"),
Remotes: meilisearch.NewOpt(map[string]meilisearch.Opt[meilisearch.UpdateRemote]{
"ms-00": meilisearch.NewOpt(meilisearch.UpdateRemote{
URL: meilisearch.String("https://meilisearch.com"),
SearchAPIKey: meilisearch.String("ReadKey"),
WriteAPIKey: meilisearch.String("WriteKey"),
}),
}),
Shards: meilisearch.NewOpt(map[string]meilisearch.Opt[meilisearch.UpdateRemoteShard]{
"ms-00": meilisearch.NewOpt(meilisearch.UpdateRemoteShard{
Remotes: meilisearch.NewOpt([]string{"ms-00"}),
}),
}),
})
let mut remotes = std::collections::HashMap::new();
remotes.insert(String::from("ms-01"), Some(meilisearch_sdk::network::RemoteConfig {
url: "https://ms-01.enterprise.meilisearch.com".to_string(),
search_api_key: "SEARCH_API_KEY".to_string(),
write_api_key: Some("WRITE_API_KEY".to_string()),
}));
// Remove ms-00 from the topology
remotes.insert(String::from("ms-00"), None);

let update = meilisearch_sdk::network::NetworkUpdate {
leader: Some("ms-01".to_string()),
remotes: Some(remotes),
..meilisearch_sdk::network::NetworkUpdate::default()
};

let task: TaskInfo = client
.update_network_state(&update)
.await
.unwrap();
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

Authorization
string
header
required

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

application/json

Network topology configuration for distributed Meilisearch

remotes
object | null

Map of remote instance names to their configurations

  • Pass null as 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.
Example:
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
shards
object | null

Map of shard names to their configurations.

  • Pass null as 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.
Example:
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
previousShards
object | null

Previous shard configurations

This field should not be passed by end-users. It is used in internal communications between Meilisearch instances

Example:
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
self
string | null

Name of this instance in the network

Example:

"ms-00"

leader
string | null

Name of the leader instance in the network

Example:

"ms-00"

previousRemotes
object | null

Previous remote configurations

This field should not be passed by end-users. It is used in internal communications between Meilisearch instances

Example:
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}

Response

New network state is returned.

Network topology configuration for distributed Meilisearch

remotes
object | null

Map of remote instance names to their configurations

  • Pass null as 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.
Example:
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}
shards
object | null

Map of shard names to their configurations.

  • Pass null as 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.
Example:
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
previousShards
object | null

Previous shard configurations

This field should not be passed by end-users. It is used in internal communications between Meilisearch instances

Example:
{
"shard-00": { "remotes": ["ms-00", "ms-01"] }
}
self
string | null

Name of this instance in the network

Example:

"ms-00"

leader
string | null

Name of the leader instance in the network

Example:

"ms-00"

previousRemotes
object | null

Previous remote configurations

This field should not be passed by end-users. It is used in internal communications between Meilisearch instances

Example:
{
"ms-00": { "url": "http://localhost:7700" },
"ms-01": { "url": "http://localhost:7701" }
}