Skip to content

feat: add new foreign keys experimental feature - #801

Open
ElyarSadig wants to merge 6 commits into
meilisearch:mainfrom
ElyarSadig:feature/foreign-keys
Open

feat: add new foreign keys experimental feature#801
ElyarSadig wants to merge 6 commits into
meilisearch:mainfrom
ElyarSadig:feature/foreign-keys

Conversation

@ElyarSadig

@ElyarSadig ElyarSadig commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Related issue

Fixes #793

What does this PR do?

  • Add new foreign keys experimental feature
  • Add new integration tests for new foreign keys methods
  • Update code samples

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features
    • Added end-to-end support for index foreign keys: retrieve, update, and reset the foreignKeys setting (with and without context).
    • Introduced public foreign-keys models and added documentation code samples for getting, updating (with field→index mappings), and resetting foreign keys.
    • Extended experimental feature settings with a fluent SetForeignKeys(enable bool) toggle, propagated through feature updates.
  • Tests
    • Added integration tests covering enabling, updating (including nil handling), retrieving, and resetting foreign keys, and updated related settings expectations.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2df78cba-2742-4163-9bc5-bf7c1ac09964

📥 Commits

Reviewing files that changed from the base of the PR and between f37d8fa and f1f3332.

📒 Files selected for processing (19)
  • mocks/meilisearch_chat_manager_mock.go
  • mocks/meilisearch_chat_reader_mock.go
  • mocks/meilisearch_document_manager_mock.go
  • mocks/meilisearch_document_reader_mock.go
  • mocks/meilisearch_index_manager_mock.go
  • mocks/meilisearch_index_reader_mock.go
  • mocks/meilisearch_key_manager_mock.go
  • mocks/meilisearch_key_reader_mock.go
  • mocks/meilisearch_search_reader_mock.go
  • mocks/meilisearch_search_rules_manager_mock.go
  • mocks/meilisearch_search_rules_reader_mock.go
  • mocks/meilisearch_service_manager_mock.go
  • mocks/meilisearch_service_reader_mock.go
  • mocks/meilisearch_settings_manager_mock.go
  • mocks/meilisearch_settings_reader_mock.go
  • mocks/meilisearch_task_manager_mock.go
  • mocks/meilisearch_task_reader_mock.go
  • mocks/meilisearch_webhook_manager_mock.go
  • mocks/meilisearch_webhook_reader_mock.go

📝 Walkthrough

Walkthrough

The SDK adds experimental foreign-key models and feature flags, public index APIs for retrieving, updating, and resetting foreign keys, integration tests using related indexes, documentation samples, and regenerated mock contracts.

Changes

Foreign keys support

Layer / File(s) Summary
Foreign-key models and contracts
models_settings.go, features.go, index_interface.go
Public models and interfaces expose foreign-key mappings and experimental feature configuration.
Foreign-key API implementation
index_settings.go
Index methods implement context and non-context GET, PUT, and DELETE operations for foreign-key settings.
Integration coverage and samples
integration/index_settings_test.go, integration/main_test.go, .code-samples.meilisearch.yaml
Tests cover enabling, updating, retrieving, and resetting foreign keys with related indexes, and samples document the operations.
Generated mock contract updates
mocks/*.go
Generated mocks add foreign-key methods, update statistics method signatures, and use any in expectation helpers.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

  • meilisearch/meilisearch-dart#491 — Implements corresponding foreign-key and document-relations SDK support.
  • meilisearch/meilisearch-php#924 — Adds matching foreign-key APIs, tests, and samples.
  • meilisearch/meilisearch-swift#525 — Covers related foreign-key settings and experimental feature support.
  • meilisearch/meilisearch-dotnet#746 — Adds corresponding APIs, models, tests, and samples.

Suggested labels: enhancement

Suggested reviewers: ja7ad

Poem

A rabbit hops where foreign keys grow,
From authors’ burrows to books below.
GET, PUT, DELETE, the paths align,
Experimental flags now brightly shine.
Tests and mocks dance in a row.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several broad mock regenerations and GetStats/StatsParams API changes are unrelated to the foreignKeys tasks in #793. Move the mock-only any-type churn and StatsParams changes into a separate PR to keep this one scoped to foreignKeys.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding the new foreignKeys experimental feature.
Linked Issues check ✅ Passed The PR implements foreignKeys settings APIs, opt-in support, tests, and code samples requested by issue #793.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jul 17, 2026
@ElyarSadig
ElyarSadig force-pushed the feature/foreign-keys branch from 6013873 to f37d8fa Compare July 17, 2026 17:19
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.69%. Comparing base (31bba01) to head (f37d8fa).

Files with missing lines Patch % Lines
index_settings.go 85.36% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #801      +/-   ##
==========================================
- Coverage   89.72%   89.69%   -0.04%     
==========================================
  Files          27       27              
  Lines        3612     3657      +45     
==========================================
+ Hits         3241     3280      +39     
- Misses        214      217       +3     
- Partials      157      160       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ElyarSadig
ElyarSadig requested a review from ja7ad July 17, 2026 17:23
ja7ad
ja7ad previously approved these changes Jul 21, 2026
@ja7ad
ja7ad added this pull request to the merge queue Jul 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 21, 2026
@ja7ad

ja7ad commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

@ElyarSadig Please improve tests and generate mocks for new APIs.

@ElyarSadig

Copy link
Copy Markdown
Collaborator Author

@ja7ad
Mocks are generated. Looking at codecov report the only missing parts are the execute request error paths (meaning meilisearch should either fail or reject the request).

@ElyarSadig

Copy link
Copy Markdown
Collaborator Author

Due to the new breaking change #802 the integration tests are now failing. We should first resolve the issue #802

@fjbarrett fjbarrett left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed this alongside #803, with OpenAI Codex assistance. The endpoint methods and live-server test flow look consistent with the foreign-keys contract. A few changes would make the public API and diff easier to maintain:

  • Please rename ForeignIndexUid to ForeignIndexUID while this type is still new. The repository consistently uses Go initialisms in exported API fields (IndexUID, TaskUID, and APIKeyUID); the JSON tag can remain foreignIndexUid.
  • The mock regeneration changes 22 unrelated mock files and also pulls in unrelated GetStats signature and interface{} to any churn. Only the mocks embedding SettingsManager or SettingsReader need foreign-key methods. Reverting the other generated changes will keep this scoped and avoid a conflict with #803 in meilisearch_service_manager_mock.go.
  • The non-context methods are covered, but the six new WithContext paths are not. Existing settings tests generally exercise context/custom-client variants; adding at least one explicit context-path case for get, update, and reset would cover request construction and cancellation plumbing.

The current integration failures are from the v1.50 Dynamic Search Rules break and should be resolved by #803 rather than this branch.

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.

[Meilisearch v1.48.0] Add document relations (experimental)

3 participants