-
Notifications
You must be signed in to change notification settings - Fork 271
v1.13: Add remote federated search documentation #3144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4d60c42
add `/network` documentation
guimachiavelli c211cda
add code samples, errors, update multi_search ref
guimachiavelli c992882
add new key permissions
guimachiavelli e1982e5
add `/network` reference to menu
guimachiavelli dae1767
add sharding guide
guimachiavelli d6233a5
pre-review fixes
guimachiavelli 24c1f46
Apply suggestions from code review
guimachiavelli 211fe84
add warning regarding sorting, network, and displayed attributes
guimachiavelli d59af65
Merge branch 'v1.13-proxy-search' of github.com:meilisearch/documenta…
guimachiavelli 43a888e
add cloud support
guimachiavelli 5011844
Merge branch 'v1.13' into v1.13-proxy-search
guimachiavelli 97f0ac0
add experimental features to table, API response
guimachiavelli 1d3a677
update sharding guidance for cloud users
guimachiavelli bc130eb
improve `feature_not_enabled` error code description
guimachiavelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| title: Implement sharding with remote federated search — Meilisearch documentation | ||
| description: This guide walks you through implemnting a sharding strategy by activating the `/network` route, configuring the network object, and performing remote federated searches. | ||
guimachiavelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| # Implement sharding with remote federated search <NoticeTag type="experimental" label="experimental" /> | ||
|
|
||
| Sharding is the process of splitting an index containing many documents into multiple smaller indexes, often called shards. This horizontal scaling technique is useful when handling large databases. In Meilisearch, the best way to implement a sharding strategy is to use remote federated search. | ||
|
|
||
| This guide walks you through activating the `/network` route, configuring the network object, and performing remote federated searches. | ||
|
|
||
| The `/network` route is not currently available on Meilisearch Cloud. | ||
|
|
||
| <Capsule intent="tip" title="Configuring multiple instances"> | ||
| To minimize issues and limit unexpected behavior, instance, network, and index configuration should be identical for all shards. This guide describes the individual steps you must take on a single instance and assumes you will replicate them across all instances. | ||
| </Capsule> | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Multiple Meilisearch projects (instances) running Meilisearch >=v1.13 | ||
|
|
||
| ## Activate the `/network` endpoint | ||
|
|
||
| First, use the `/experimental-features` route to enable `network`: | ||
guimachiavelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```sh | ||
| curl \ | ||
| -X PATCH 'MEILISEARCH_URL/experimental-features/' \ | ||
| -H 'Content-Type: application/json' \ | ||
| --data-binary '{ | ||
| "network": true | ||
| }' | ||
| ``` | ||
|
|
||
| Meilisearch should respond immediately, confirming the route is now accessible. | ||
|
|
||
| ## Configuring the network object | ||
|
|
||
| Next, you must configure the network object. It consists of the following fields: | ||
|
|
||
| - `remotes`: defines a list with the required information to access each remote instance | ||
| - `self`: specifies which of the configured `remotes` corresponds to the current instance | ||
|
|
||
| ### Setting up remote instances | ||
|
|
||
| Use the `/network` route to configure the `remotes` field of the network object. `remotes` should be an object containing one or more objects. Each one of the nested objects should consist of the name of each instance, associated with its URL and an API key with search permission: | ||
|
|
||
| ```sh | ||
| curl \ | ||
| -X PATCH 'MEILISEARCH_URL/network' \ | ||
| -H 'Content-Type: application/json' \ | ||
| --data-binary '{ | ||
| "remotes": { | ||
| "REMOTE_NAME_1": { | ||
| "url": "INSTANCE_URL_1", | ||
| "searchApiKey": "SEARCH_API_KEY_1" | ||
| }, | ||
| "REMOTE_NAME_2": { | ||
| "url": "INSTANCE_URL_2", | ||
| "searchApiKey": "SEARCH_API_KEY_2" | ||
| }, | ||
| "REMOTE_NAME_3": { | ||
| "url": "INSTANCE_URL_3", | ||
| "searchApiKey": "SEARCH_API_KEY_3" | ||
| }, | ||
| … | ||
| } | ||
| }' | ||
| ``` | ||
|
|
||
| Configure the entire set of remote instances in your sharded database, making sure to send the same remotes to each instance. | ||
|
|
||
| ### Specify the name of the current instance | ||
|
|
||
| Now all instances share the same list of remotes, set the `self` field to specify which of the remotes corresponds to the current instance: | ||
|
|
||
| ```sh | ||
| curl \ | ||
| -X PATCH 'MEILISEARCH_URL/network' \ | ||
| -H 'Content-Type: application/json' \ | ||
| --data-binary '{ | ||
| "self": "REMOTE_NAME_1" | ||
| } | ||
guimachiavelli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| Meilisearch processes searches on the remote that corresponds to `self` locally instead of making a remote request. | ||
| ### Adding or removing an instance | ||
| Changing the topology of the network involves moving some documents from an instance to another, depending on your hashing scheme. | ||
| As Meilisearch does not provide atomicity across multiple instances, you will need to either: | ||
| 1. accept search downtime while migrating documents | ||
| 2. accept some documents will not appear in search results during the migration | ||
| 3. accept some duplicate documents may appear in search results during the migration | ||
| #### Reducing downtime | ||
| If your disk space allows, you can reduce the downtime by applying the following algorithm: | ||
| 1. Create a new temporary index in each remote instance | ||
| 2. Compute the new instance for each document | ||
| 3. Send the documents to the temporary index of their new instance | ||
| 4. Once Meilisearch has copied all documents to their instance of destination, swap the new index with the previously used index | ||
| 5. Delete the temporary index after the swap | ||
| 6. Update network configuration and search queries across all instances | ||
| ## Create indexes and add documents | ||
| Create the same empty indexes with the same settings on all instances. Keeping the settings and indexes in sync is important to avoid errors and unexpected behavior, though not strictly required. | ||
| Distribute your documents across all instances. Do not send the same document to multiple instances as this may lead to duplicate search results. Similarly, you should ensure all future versions of a document are sent to the same instance. Meilisearch recommends you hash their primary key using [rendezvous hashing](https://en.wikipedia.org/wiki/Rendezvous_hashing). | ||
| ### Updating index settings | ||
| Changing settings in a sharded database is not fundamentally different from changing settings on a single Meilisearch instance. If the update enables a feature, such as setting filterable attributes, wait until all changes have been processed before using the `filter` search parameter in a query. Likewise, if an update disables a feature, first remove it from your search requests, then update your settings. | ||
| ## Perform a search | ||
| Send your federated search request containing one query per instance: | ||
| <CodeSamples id="multi_search_remote_federated_1" /> | ||
| If all instances share the same network configuration, you can send the search request to any instance. Having `"remote": "ms-00"` appear in the list of queries on the instance of that name will not cause an actual proxy search thanks to `network.self`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.