Skip to content

Commit 98fbe2c

Browse files
guimachiavelligithub-actions[bot]Kerollmops
authored
v1.16: /export route (#3315)
* add `/export` route * Update code samples [skip ci] * Apply suggestions from code review Co-authored-by: Clément Renault <[email protected]> * Update code samples [skip ci] * clarify exporting data into existing indexes * Update reference/api/export.mdx Co-authored-by: Clément Renault <[email protected]> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Clément Renault <[email protected]>
1 parent 3ae5457 commit 98fbe2c

15 files changed

+198
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,18 @@ related_results_similar_1: |-
14671467
"id": 192,
14681468
"embedder": "EMBEDDER_NAME"
14691469
}'
1470+
export_post_1: |-
1471+
curl \
1472+
-X POST 'MEILISEARCH_URL/export' \
1473+
-H 'Content-Type: application/json' \
1474+
--data-binary '{
1475+
"url": "TARGET_INSTANCE_URL",
1476+
"indexes": {
1477+
"*": {
1478+
"overrideSettings": true
1479+
}
1480+
}
1481+
}'
14701482
14711483
### Code samples for experimental features
14721484
experimental_get_metrics_1: |-

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@
349349
"reference/api/dump",
350350
"reference/api/experimental_features",
351351
"reference/api/metrics",
352-
"reference/api/logs"
352+
"reference/api/logs",
353+
"reference/api/export"
353354
]
354355
},
355356
{

reference/api/export.mdx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Export
3+
description: "Migrate between instances with the `/export` route"
4+
---
5+
6+
import { RouteHighlighter } from '/snippets/route_highlighter.mdx'
7+
8+
import CodeSamplesExperimentalDeleteLogsStream1 from '/snippets/samples/code_samples_experimental_delete_logs_stream_1.mdx';
9+
10+
Use the `/export` route to transfer data from your origin instance to a remote target instance. This is particularly useful when migrating from your local development environment to a Meilisearch Cloud instance.
11+
12+
## Migrate database between instances
13+
14+
<RouteHighlighter method="POST" path="/export" />
15+
16+
Migrate data from the origin instance to a target instance.
17+
18+
Migration is an additive operation. If the exported indexes already exist in the target instance, Meilisearch keeps the existing documents intact and adds the new data to the index. If the same document is present in both the target and origin, Meilisearch replaces the target documents with the new data.
19+
20+
### Body
21+
22+
| Name | Type | Default value | Description |
23+
| ------------------- | ------ | ------------- | --------------------------------------------------------------------------------------------------------- |
24+
| **`url`** * | String | `null` | The target instance's URL address. Required |
25+
| **`apiKey`** * | String | `null` | An API key with full admin access to the target instance |
26+
| **`payloadSize`** * | String | "50 MiB" | A string specifying the payload size in a human-readable format |
27+
| **`indexes`** * | Object | `null` | A set of patterns matching the indexes you want to export. Defaults to all indexes in the origin instance |
28+
29+
#### `url`
30+
31+
A string pointing to a remote Meilisearch instance, including its port if necessary.
32+
33+
This field is required.
34+
35+
#### `apiKey`
36+
37+
A security key with `index.create`, `settings.update`, and `documents.add` permissions to a secured Meilisearch instance.
38+
39+
#### `payloadSize`
40+
41+
The maximum size of each single data payload in a human-readable format such as `"100MiB"`. Larger payloads are generally more efficient, but require significantly more powerful machines.
42+
43+
#### `indexes`
44+
45+
A set of objects whose keys correspond to patterns matching the indexes you want to export. By default, Meilisearch exports all documents across all indexes.
46+
47+
Meilisearch does not override any index settings by default. If the target instance contains an index with the same name as an index you're exporting, Meilisearch uses the settings in the target instance. If the index does not already exist in the target instance, Meilisearch uses the settings in the origin instance.
48+
49+
Each index object accepts the following fields:
50+
51+
- `filter`: a [filter expression](/learn/filtering_and_sorting/filter_expression_reference) defining the subset of documents to export. Optional, defaults to `null`
52+
- `overrideSettings`: if `true`, configures indexes in the target instance with the origin instance settings. Optional, defaults to `false`
53+
54+
### Example
55+
56+
<CodeSamplesExportPost1 />
57+
58+
#### Response
59+
60+
```json
61+
{
62+
"taskUid": 2,
63+
"indexUid": null,
64+
"status": "enqueued",
65+
"type": "export",
66+
"enqueuedAt": "2025-06-26T12:54:10.785864Z"
67+
}
68+
```

reference/errors/error_codes.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,26 @@ This error occurs if:
192192

193193
The provided `_geo` field of one or more documents is invalid. Meilisearch expects `_geo` to be an object with two fields, `lat` and `lng`, each containing geographic coordinates expressed as a string or floating point number. Read more about `_geo` and how to troubleshoot it in [our dedicated guide](/learn/filtering_and_sorting/geosearch).
194194

195+
## `invalid_export_url`
196+
197+
The export target instance URL is invalid or could not be reached.
198+
199+
## `invalid_export_api_key`
200+
201+
The supplied security key does not have the required permissions to access the target instance.
202+
203+
## `invalid_export_payload_size`
204+
205+
The provided payload size is invalid. The payload size must be a string indicating the maximum payload size in a human-readable format.
206+
207+
## `invalid_export_indexes_patterns`
208+
209+
The provided index pattern is invalid. The index pattern must be an alphanumeric string, optionally including a wildcard.
210+
211+
## `invalid_export_index_filter`
212+
213+
The provided index export filter is not a valid [filter expression](/learn/filtering_and_sorting/filter_expression_reference).
214+
195215
## `invalid_facet_search_facet_name`
196216

197217
The attribute used for the `facetName` field is either not a string or not defined in the [`filterableAttributes` list](/reference/api/settings#filterable-attributes).

snippets/samples/code_samples_async_guide_filter_by_statuses_2.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<CodeGroup>
22

3+
```rust Rust
4+
let mut query = TasksQuery::new(&client);
5+
let tasks = query
6+
.with_statuses(["failed", "canceled"])
7+
.execute()
8+
.await
9+
.unwrap();
10+
```
11+
312
```rust Rust
413
let mut query = TasksQuery::new(&client);
514
let tasks = query

snippets/samples/code_samples_basic_security_tutorial_admin_1.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<CodeGroup>
22

3+
```rust Rust
4+
let client = Client::new("http://localhost:7700", Some("DEFAULT_ADMIN_API_KEY"));
5+
let task = client
6+
.create_index("medical_records", Some("id"))
7+
.await
8+
.unwrap();
9+
```
10+
311
```rust Rust
412
let client = Client::new("http://localhost:7700", Some("DEFAULT_ADMIN_API_KEY"));
513
let task = client

snippets/samples/code_samples_basic_security_tutorial_listing_1.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<CodeGroup>
22

3+
```rust Rust
4+
let client = Client::new("http://localhost:7700", Some("MASTER_KEY"));
5+
client
6+
.get_keys()
7+
.await
8+
.unwrap();
9+
```
10+
311
```rust Rust
412
let client = Client::new("http://localhost:7700", Some("MASTER_KEY"));
513
client

snippets/samples/code_samples_basic_security_tutorial_search_1.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<CodeGroup>
22

3+
```rust Rust
4+
let client = Client::new("http://localhost:7700", Some("DEFAULT_SEARCH_API_KEY"));
5+
let index = client.index("medical_records");
6+
index
7+
.search()
8+
.with_query("appointments")
9+
.execute::<MedicalRecord>()
10+
.await
11+
.unwrap();
12+
```
13+
314
```rust Rust
415
let client = Client::new("http://localhost:7700", Some("DEFAULT_SEARCH_API_KEY"));
516
let index = client.index("medical_records");

snippets/samples/code_samples_index_settings_tutorial_api_get_setting_1.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<CodeGroup>
22

3+
```rust Rust
4+
let searchable_attributes: Vec<String> = index
5+
.get_searchable_attributes()
6+
.await
7+
.unwrap();
8+
```
9+
310
```rust Rust
411
let searchable_attributes: Vec<String> = index
512
.get_searchable_attributes()

snippets/samples/code_samples_index_settings_tutorial_api_put_setting_1.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<CodeGroup>
22

3+
```rust Rust
4+
let task = index
5+
.set_searchable_attributes(["title", "overview"])
6+
.await
7+
.unwrap();
8+
```
9+
310
```rust Rust
411
let task = index
512
.set_searchable_attributes(["title", "overview"])

0 commit comments

Comments
 (0)