Skip to content

Conversation

flevi29
Copy link
Collaborator

@flevi29 flevi29 commented Sep 26, 2025

Pull Request

Related issue

Fixes #1989

What does this PR do?

  • adds method
  • tests method
  • adds code sample

Summary by CodeRabbit

  • New Features

    • Added a data export capability: export to a destination URL with optional API key, configurable payload size, per-index filters and settings overrides; exports are tracked as an Export task type.
  • Documentation

    • Added a code sample demonstrating export usage.
  • Tests

    • Added tests validating export flows, task completion, and task type reporting.
  • Chores

    • CI and local setups now run an additional Meilisearch instance to support export testing.

@flevi29 flevi29 added the enhancement New feature or request label Sep 26, 2025
Copy link

coderabbitai bot commented Sep 26, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds Meilisearch /export support: new Export types, MeiliSearch.export() method, an integration test for export, a code-sample entry, and CI/docker changes adding a second Meilisearch service bound to host port 7702 for export-related tests.

Changes

Cohort / File(s) Summary of Changes
Client & Types
src/meilisearch.ts, src/types/export.ts, src/types/index.ts, src/types/task_and_batch.ts
Adds ExportOptions, ExportIndexSettings and related types; re-exports them; extends TaskType with "Export"; adds MeiliSearch.export(options) which POSTs to /export and returns an EnqueuedTaskPromise.
Tests & test utilities
tests/export.test.ts, tests/utils/meilisearch-test-utils.ts, tests/utils/tasks-and-batches.ts
Adds integration test exercising export, waits for task completion and asserts type/status; updates test utilities to accept the export task type.
CI workflows
.github/workflows/tests.yml, .github/workflows/pre-release-tests.yml, .github/workflows/meilisearch-prototype-tests.yml
Adds an export-meilisearch service alongside meilisearch, using the same image/env and exposing host port 7702:7700 for integration/pre-release/prototype test jobs.
Local compose
docker-compose.yml
Adds export-meilisearch service mirroring meilisearch, exposing host port 7702:7700.
Code sample
.code-samples.meilisearch.yaml
Adds export_post_1 sample demonstrating client.export with url, indexes (wildcard) and overrideSettings: true.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Tester as Test / Caller
  participant Client as MeiliSearch Client
  participant Server as Meilisearch Server

  Tester->>Client: export(options)
  Note right of Client #e9f7ef: Build payload (url, apiKey?, payloadSize?, indexes)
  Client->>Server: POST /export
  Server-->>Client: 202 Accepted + task { uid, type: "export" }
  Client-->>Tester: EnqueuedTaskPromise (uid)

  par poll status
    Tester->>Client: waitForTask(uid) / poll
    Client->>Server: GET /tasks/:uid
    Server-->>Client: task status (succeeded/failed)
  end
  Client-->>Tester: Final task result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

documentation

Suggested reviewers

  • Strift
  • nicolasvienot

Poem

I nibble code and hop with glee,
Two Meilisearches hum on 7702,
Types and export calls now roam free,
A test queues tasks and sees them through.
Rabbit cheers — export delivered true! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request introduces new CI service definitions in multiple GitHub workflow files and in docker-compose.yml by adding an export-meilisearch service on port 7702, which was not requested in the linked issue objectives and appears unrelated to implementing the export API. Please remove or justify the CI workflow and docker-compose service additions to keep this PR focused on the export API implementation, or move those configuration changes into a separate PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title “Add export method feature” clearly and concisely conveys the primary change of introducing the export method functionality to the MeiliSearch client without extraneous detail.
Linked Issues Check ✅ Passed The changeset adds the export method in src/meilisearch.ts with corresponding TypeScript types and re-exports, updates task types, includes unit tests for export functionality, and adds the example code snippet in .code-samples.meilisearch.yaml, thereby satisfying all objectives of linked issue #1989.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
docker-compose.yml (1)

24-30: Pin image tag to latest for consistency.

Other workflows pin to getmeili/meilisearch:latest. Recommend doing the same here.

Apply this diff:

-  export-meilisearch:
-    image: getmeili/meilisearch
+  export-meilisearch:
+    image: getmeili/meilisearch:latest
tests/export.test.ts (1)

24-38: Parameterize hardcoded MeiliSearch URLs for portability.

Avoid embedding http://127.0.0.1:7701 in tests—read both the export host and BAD_HOST from env vars with sensible defaults:

diff --git a/tests/export.test.ts b/tests/export.test.ts
--- a/tests/export.test.ts
+++ b/tests/export.test.ts
@@
- test(`${ms.export.name} method`, async () => {
-   const task = await ms
-     .export({
-       url: "http://127.0.0.1:7701",
+const EXPORT_URL = process.env.MEILISEARCH_EXPORT_URL ?? "http://127.0.0.1:7701";
+
+test(`${ms.export.name} method`, async () => {
+  const task = await ms
+    .export({
+      url: EXPORT_URL,
       apiKey: "masterKey",
       payloadSize: "50MiB",
       indexes: {
         [INDEX_UID]: { filter: "beep = boop", overrideSettings: true },
       },
     })
     .waitTask({ timeout: 60_000 });
diff --git a/tests/utils/meilisearch-test-utils.ts b/tests/utils/meilisearch-test-utils.ts
--- a/tests/utils/meilisearch-test-utils.ts
+++ b/tests/utils/meilisearch-test-utils.ts
@@
-const BAD_HOST = "http://127.0.0.1:7701";
+const BAD_HOST = process.env.MEILISEARCH_BAD_HOST_URL ?? "http://127.0.0.1:7701";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f7c885 and 663f1f2.

📒 Files selected for processing (10)
  • .code-samples.meilisearch.yaml (1 hunks)
  • .github/workflows/meilisearch-prototype-tests.yml (1 hunks)
  • .github/workflows/pre-release-tests.yml (1 hunks)
  • .github/workflows/tests.yml (1 hunks)
  • docker-compose.yml (1 hunks)
  • src/meilisearch.ts (2 hunks)
  • src/types/export.ts (1 hunks)
  • src/types/index.ts (1 hunks)
  • src/types/task_and_batch.ts (1 hunks)
  • tests/export.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-01T08:07:25.043Z
Learnt from: flevi29
PR: meilisearch/meilisearch-js#1977
File: docker-compose.yml:17-17
Timestamp: 2025-07-01T08:07:25.043Z
Learning: In the meilisearch-js project, both the docker-compose.yml and the main CI workflow (.github/workflows/tests.yml) use `getmeili/meilisearch:latest` to maintain consistency between local development and CI testing environments.

Applied to files:

  • docker-compose.yml
  • .github/workflows/pre-release-tests.yml
  • .github/workflows/tests.yml
  • .github/workflows/meilisearch-prototype-tests.yml
📚 Learning: 2025-07-01T08:07:25.043Z
Learnt from: flevi29
PR: meilisearch/meilisearch-js#1977
File: docker-compose.yml:17-17
Timestamp: 2025-07-01T08:07:25.043Z
Learning: In the meilisearch-js project, both the docker-compose.yml and CI workflows use the latest Meilisearch image (getmeili/meilisearch:latest) for consistency between development and testing environments.

Applied to files:

  • docker-compose.yml
  • .github/workflows/pre-release-tests.yml
  • .github/workflows/tests.yml
  • .github/workflows/meilisearch-prototype-tests.yml
🧬 Code graph analysis (2)
src/types/export.ts (1)
src/types/types.ts (1)
  • Filter (170-170)
src/meilisearch.ts (2)
src/types/export.ts (1)
  • ExportOptions (21-30)
src/types/task_and_batch.ts (1)
  • EnqueuedTaskPromise (160-166)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: integration-tests (Node.js 20)
  • GitHub Check: integration-tests (Node.js 22)
🔇 Additional comments (8)
src/types/task_and_batch.ts (1)

55-57: TaskType includes Export — LGTM.

Matches test expectation task.type === "export" and server naming.

src/types/index.ts (1)

2-2: Re-export of export types — LGTM.

Public surface now exposes ExportOptions and related types.

src/meilisearch.ts (2)

37-38: Type import — LGTM.

Importing ExportOptions from types index is consistent with the rest.


551-558: New export() method — LGTM.

Consistent with dumps/snapshots (POST + enqueued task). Endpoint path name aligns with tests.

.github/workflows/meilisearch-prototype-tests.yml (1)

47-53: Second Meilisearch service — LGTM.

Provides dedicated export target on 7701 for integration tests.

.github/workflows/tests.yml (1)

36-42: Second Meilisearch service — LGTM.

Parity with docker-compose and other workflows; enables export tests reliably.

src/types/export.ts (1)

1-30: Type definitions align with the export API contract

Filter and override settings mirror the server-side struct, and the options shape matches the documented payload. Looks good.

.github/workflows/pre-release-tests.yml (1)

37-50: Second Meilisearch service configuration looks consistent

Image, env, and port mapping mirror the primary service while exposing 7701 for export tests, keeping parity with the existing workflow setup.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
docker-compose.yml (1)

24-30: Explicitly pin the export image tag.
Lines 24-30 currently pull getmeili/meilisearch without an explicit tag. To keep parity with our CI workflows and avoid tracking a moving default, please pin both services to getmeili/meilisearch:latest.

   meilisearch:
-    image: getmeili/meilisearch
+    image: getmeili/meilisearch:latest
@@
   export-meilisearch:
-    image: getmeili/meilisearch
+    image: getmeili/meilisearch:latest

Based on learnings

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 663f1f2 and b9d1a47.

📒 Files selected for processing (7)
  • .github/workflows/meilisearch-prototype-tests.yml (1 hunks)
  • .github/workflows/pre-release-tests.yml (1 hunks)
  • .github/workflows/tests.yml (1 hunks)
  • docker-compose.yml (1 hunks)
  • tests/export.test.ts (1 hunks)
  • tests/utils/meilisearch-test-utils.ts (1 hunks)
  • tests/utils/tasks-and-batches.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/pre-release-tests.yml
  • .github/workflows/meilisearch-prototype-tests.yml
  • tests/export.test.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-01T08:07:25.043Z
Learnt from: flevi29
PR: meilisearch/meilisearch-js#1977
File: docker-compose.yml:17-17
Timestamp: 2025-07-01T08:07:25.043Z
Learning: In the meilisearch-js project, both the docker-compose.yml and the main CI workflow (.github/workflows/tests.yml) use `getmeili/meilisearch:latest` to maintain consistency between local development and CI testing environments.

Applied to files:

  • .github/workflows/tests.yml
  • docker-compose.yml
📚 Learning: 2025-07-01T08:07:25.043Z
Learnt from: flevi29
PR: meilisearch/meilisearch-js#1977
File: docker-compose.yml:17-17
Timestamp: 2025-07-01T08:07:25.043Z
Learning: In the meilisearch-js project, both the docker-compose.yml and CI workflows use the latest Meilisearch image (getmeili/meilisearch:latest) for consistency between development and testing environments.

Applied to files:

  • .github/workflows/tests.yml
  • docker-compose.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: integration-tests (Node.js 22)
  • GitHub Check: integration-tests (Node.js 20)
🔇 Additional comments (3)
.github/workflows/tests.yml (1)

36-42: Nice parity for the second Meilisearch service.
Mirroring the primary service config on port 7702 keeps the integration environment consistent for the new export coverage.

tests/utils/meilisearch-test-utils.ts (1)

200-204: Task assertion updated for export tasks.
With export included here, the shared assertions stay aligned with the expanded TaskType union.

tests/utils/tasks-and-batches.ts (1)

30-34: Helper keeps pace with the new task type.
Adding export ensures the task-type assertions accept the export jobs emitted by the API.

@flevi29
Copy link
Collaborator Author

flevi29 commented Sep 26, 2025

Seems like this export method doesn't quite work. It shouldn't take 1 minute + to transfer an index with one tiny document and its default settings.

@flevi29
Copy link
Collaborator Author

flevi29 commented Sep 26, 2025

TODO: Task detail types:

    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub api_key: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub payload_size: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexes: Option<BTreeMap<String, DetailsExportIndexSettings>>,

Copy link
Collaborator

@Strift Strift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @flevi29 and thanks for this PR 🙌 Just left a small suggestion to align the code sample with the meilisearch docs.

@Strift Strift marked this pull request as draft October 2, 2025 06:58
@flevi29 flevi29 marked this pull request as ready for review October 2, 2025 07:08
@flevi29 flevi29 marked this pull request as draft October 2, 2025 07:08
@flevi29
Copy link
Collaborator Author

flevi29 commented Oct 2, 2025

Seems like this export method doesn't quite work. It shouldn't take 1 minute + to transfer an index with one tiny document and its default settings.

Hi @Strift, someone needs to check this out. I think it's a bug.

test(`${ms.export.name} method`, async () => {
const task = await ms
.export({
url: "http://127.0.0.1:7702",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work in Docker? Shouldn't we use the service's internal name, e.g., http://export-meilisearch:7700?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, you're right. Nevertheless it should err and not hang, so it still counts as a bug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, now I get:

{
  "code": "internal",
  "link": "https://docs.meilisearch.com/errors#internal",
  "message": "Failed to export documents to remote server missing_payload (invalid_request): A ndjson payload is missing. <https://docs.meilisearch.com/errors#missing_payload>",
  "type": "internal",
}

Not sure what the problem is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1.16] Add support for /export API
2 participants