Skip to content

Commit 1cbda4a

Browse files
committed
Apply Kerollmops review: remove useNetwork from examples, simplify replication description, full-sharding setup, no-fallback note, fix wording throughout
1 parent ab07fee commit 1cbda4a

4 files changed

Lines changed: 33 additions & 31 deletions

File tree

resources/self_hosting/sharding/configure_replication.mdx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Replication requires the Meilisearch Enterprise Edition v1.37 or later and a [co
1212

1313
## How replication works
1414

15-
When you configure shards, each shard can be assigned to one or more remotes. If a shard is assigned to multiple remotes, Meilisearch replicates the data to each of them. During a search with `useNetwork: true`, Meilisearch queries each shard exactly once, picking one of the available remotes for each shard. This avoids duplicate results.
15+
When you configure shards, each shard can be assigned to one or more remotes. If a shard is assigned to multiple remotes, Meilisearch replicates the data to each of them. During a search, Meilisearch queries each shard exactly once, picking one of the available remotes for each shard (prioritizing the `self`/local remote). This avoids duplicate results.
1616

1717
## Assign shards to multiple remotes
1818

@@ -83,15 +83,13 @@ Place replicas in different regions to reduce latency for geographically distrib
8383
}
8484
```
8585

86-
Route search requests to the closest cluster. Both regions hold all data, so either can serve a full result set.
86+
Route search requests to the closest cluster. Both regions hold all data, so either can serve a full result set. By default, Meilisearch prioritizes local search requests and will not transfer the request to a remote server. Make sure your search requests are made on the closest remote instance to ensure this setup is efficient.
8787

8888
## Remote availability
8989

90-
When a network search runs, Meilisearch builds an internal partition: it assigns each shard to exactly one remote, then sends one query per remote with a shard filter. This guarantees no shard is queried twice and results are never duplicated.
90+
When a network search runs, Meilisearch builds an internal set of remotes to query: it assigns each shard to a remote, then sends one query per remote with a shard filter. This guarantees that no shard is queried twice and that results are never duplicated.
9191

92-
The downside is that there is no automatic fallback. If the remote assigned to a shard is unreachable, that shard's results are missing from the response — Meilisearch does not retry using another replica that holds the same shard.
93-
94-
To handle remote failures, route search traffic away from unhealthy instances at the infrastructure level (for example, using a load balancer with health checks). When the failed remote comes back online, it can start serving searches again without manual intervention.
92+
The downside is that there is no automatic fallback. If the remote assigned to a shard is unreachable, that shard's results are missing from the response — Meilisearch does not yet retry using another replica that holds the same shard.
9593

9694
## Scaling read throughput
9795

@@ -130,8 +128,8 @@ The leader is responsible for all write operations (document additions, settings
130128

131129
If the leader goes down:
132130

133-
- **Search may be affected**: if search requests are routed to the downed leader, they will fail. Route search traffic to healthy instances using a load balancer
134-
- **Writes are blocked**: no documents can be added or updated until a leader is available
131+
- **Search may be affected**: if search requests are routed to the downed leader, they will fail
132+
- **Writes are blocked**: no documents can be added or updated until a leader is available. Note that alive remote instances continue to process tasks
135133
- **Manual promotion**: you must designate a new leader by updating the network topology with `PATCH /network` and setting `"leader"` to another instance
136134

137135
<Warning>

resources/self_hosting/sharding/manage_network.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ curl \
8989

9090
When you modify shard assignments, Meilisearch triggers a `NetworkTopologyChange` task on all remotes. This task runs in three steps:
9191

92-
1. **Compute new shards**: each instance uses rendezvous hashing to determine which documents now belong to which shard under the new topology.
92+
1. **Compute new shards**: each instance uses rendezvous hashing on document IDs to determine which documents belong to which shard under the new topology.
9393
2. **Export and import**: documents are sent to remotes that now own them.
9494
3. **Delete stale data**: once all remotes confirm their imports are complete, each instance deletes the documents it no longer owns. Search switches to the new shard definitions at this point.
9595

@@ -121,7 +121,6 @@ curl \
121121
-H 'Authorization: Bearer MEILISEARCH_KEY' \
122122
--data-binary '{
123123
"q": "batman",
124-
"useNetwork": true,
125124
"filter": "_shard = \"shard-a\""
126125
}'
127126
```
@@ -132,9 +131,9 @@ Supported `_shard` filter operators:
132131

133132
| Syntax | Behavior |
134133
|--------|----------|
135-
| `_shard = "shard-a"` | Results from `shard-a` only |
136-
| `_shard != "shard-a"` | Results from all shards except `shard-a` |
137-
| `_shard IN ["shard-a", "shard-b"]` | Results from both `shard-a` and `shard-b` |
134+
| `_shard = "shard-a"` | Documents associated to `shard-a` |
135+
| `_shard != "shard-a"` | Documents associated to all shards except `shard-a` |
136+
| `_shard IN ["shard-a", "shard-b"]` | Documents associated to both `shard-a` and `shard-b` |
138137

139138
## Private network security
140139

resources/self_hosting/sharding/overview.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ graph TD
3434
Any -->|merged results| Client
3535
```
3636

37-
1. **Network**: the leader configures the topology via `/network` and propagates it to all remotes
38-
2. **Shards**: the leader distributes document subsets across remotes based on shard assignments
39-
3. **Search**: when `useNetwork: true` is set, the instance receiving the request fans out the search to all remotes, then merges and ranks the combined results
37+
1. **Network**: the user configures the topology via `/network` on the leader, and this instance propagates it to all remotes
38+
2. **Shards**: Remotes distribute the subsets of documents across themselves based on shard assignments
39+
3. **Search**: when `useNetwork: true` is set or not defined (defaults to `true`), the instance receiving the request fans out the search to all remotes, then merges and ranks the combined results
4040

4141
## When to use sharding and replication
4242

@@ -60,7 +60,11 @@ The leader instance is responsible for write operations and topology changes. No
6060

6161
## Searching across the network
6262

63-
To search across all instances, add `useNetwork: true` to your search request:
63+
To search across all instances:
64+
65+
<Note>
66+
`useNetwork` defaults to `true` when a network topology is defined.
67+
</Note>
6468

6569
<CodeGroup>
6670

@@ -70,8 +74,7 @@ curl \
7074
-H 'Content-Type: application/json' \
7175
-H 'Authorization: Bearer MEILISEARCH_KEY' \
7276
--data-binary '{
73-
"q": "batman",
74-
"useNetwork": true
77+
"q": "batman"
7578
}'
7679
```
7780

@@ -82,7 +85,6 @@ The response includes `_federation` metadata showing which remote each result ca
8285
```json
8386
{
8487
"q": "batman",
85-
"useNetwork": true,
8688
"filter": "_shard = \"shard-a\""
8789
}
8890
```
@@ -100,8 +102,8 @@ curl \
100102
-H 'Authorization: Bearer MEILISEARCH_KEY' \
101103
--data-binary '{
102104
"queries": [
103-
{ "indexUid": "movies", "q": "batman", "useNetwork": true },
104-
{ "indexUid": "comics", "q": "batman", "useNetwork": true }
105+
{ "indexUid": "movies", "q": "batman" },
106+
{ "indexUid": "comics", "q": "batman" }
105107
]
106108
}'
107109
```
@@ -119,7 +121,7 @@ Most Meilisearch features work transparently across a sharded network. The follo
119121
| Faceted search | Partial | Facet distribution in search results works across remotes, but the `/facet-search` endpoint does not support `useNetwork` |
120122
| Hybrid/semantic search | Yes | Each remote runs its own vector search, results merged |
121123
| Geo search | Yes | Geographic filters and sorting work across remotes |
122-
| Multi-search | Yes | Use `useNetwork: true` per query |
124+
| Multi-search | Yes | Works per query; `useNetwork` defaults to `true` when a network is configured |
123125
| Federated search | Yes | Federation merges results from both indexes and remotes |
124126
| Analytics | Partial | Events are tracked on the instance that receives the search request |
125127
| Tenant tokens | Yes | Token filters apply on each remote |

resources/self_hosting/sharding/setup_sharded_cluster.mdx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,20 @@ curl \
8989
}
9090
},
9191
"shards": {
92-
"shard-a": { "remotes": ["ms-00", "ms-01"] },
93-
"shard-b": { "remotes": ["ms-01", "ms-02"] },
94-
"shard-c": { "remotes": ["ms-02", "ms-00"] }
92+
"shard-a": { "remotes": ["ms-00"] },
93+
"shard-b": { "remotes": ["ms-01"] },
94+
"shard-c": { "remotes": ["ms-02"] }
9595
}
9696
}'
9797
```
9898

9999
</CodeGroup>
100100

101-
In this configuration, each shard is replicated across two remotes. If any single instance goes down, all shard data still exists on another instance.
101+
In this configuration, each shard lives on exactly one remote. Documents are distributed across all three instances, and each instance handles searches for its own shards.
102+
103+
<Note>
104+
This setup has no replication. If a remote becomes unavailable, its shards are missing from search results — Meilisearch does not yet automatically fall back to another instance. See [Configure replication](/resources/self_hosting/sharding/configure_replication) for a high-availability setup.
105+
</Note>
102106

103107
## Step 4: Index documents
104108

@@ -126,7 +130,7 @@ All write operations (document additions, updates, deletions, settings changes)
126130

127131
## Step 5: Search across the cluster
128132

129-
Search requests can be sent to any instance in the network, not just the leader. Add `useNetwork: true` to query all remotes:
133+
Search requests can be sent to any instance in the network, not just the leader. `useNetwork` defaults to `true` when a network topology is defined:
130134

131135
<CodeGroup>
132136

@@ -136,14 +140,13 @@ curl \
136140
-H 'Content-Type: application/json' \
137141
-H 'Authorization: Bearer SEARCH_KEY_00' \
138142
--data-binary '{
139-
"q": "batman",
140-
"useNetwork": true
143+
"q": "batman"
141144
}'
142145
```
143146

144147
</CodeGroup>
145148

146-
Meilisearch fans out the search to all remotes, collects results from each shard, and returns a single merged response.
149+
Meilisearch fans out the search to all shards, collects results from each shard, and returns a single merged response.
147150

148151
## Verify the topology
149152

0 commit comments

Comments
 (0)