Skip to content

Add dynamic search rules#2171

Open
Strift wants to merge 6 commits intomainfrom
feat/add-dynamic-search-rules
Open

Add dynamic search rules#2171
Strift wants to merge 6 commits intomainfrom
feat/add-dynamic-search-rules

Conversation

@Strift
Copy link
Copy Markdown
Collaborator

@Strift Strift commented Apr 14, 2026

Pull Request

Related issue

Fixes #2167

What does this PR do?

  • Add methods to create/update, list, and delete dynamic search rules
  • Bump Meilisearch version used in the repo to v1.42
  • Fix a small test that broke on v1.42

AI disclosure

Cursor with gpt-5.1-high and codex-5.3-medium

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 dynamic search rules API to list, retrieve, update, and delete rules.
  • Chores

    • Updated Meilisearch runtime from v1.40 to v1.42.
  • Documentation

    • Added code samples demonstrating dynamic search rules operations.
  • Types

    • Exposed new types and an experimental feature flag to support dynamic search rules.
  • Tests

    • Added end-to-end tests for dynamic search rules (create, list, fetch, delete).

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

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: 17bc1df8-126f-499b-9065-2bc22e06f214

📥 Commits

Reviewing files that changed from the base of the PR and between 4b55b1d and 3c7bf9c.

📒 Files selected for processing (1)
  • tests/experimental-features.test.ts

📝 Walkthrough

Walkthrough

Adds Dynamic Search Rules support: new types, four SDK methods (list, get, patch, delete), tests and code samples, and bumps Meilisearch runtime from v1.40 to v1.42. Also includes a minor timeout simplification and a small test assertion adjustment.

Changes

Cohort / File(s) Summary
Configuration
\.github/workflows/tests.yml, docker-compose.yml
Bumped Meilisearch service image from getmeili/meilisearch-enterprise:v1.40 to getmeili/meilisearch-enterprise:v1.42.
Type Definitions
src/types/search-rules.ts, src/types/index.ts, src/types/experimental-features.ts
Added search-rules.ts with exported types for dynamic search rules and re-exported it from src/types/index.ts. Added `dynamicSearchRules?: boolean
SDK API
src/meilisearch.ts
Added four public methods: getDynamicSearchRules(parameters?), getDynamicSearchRule(uid), updateDynamicSearchRule(uid, rule), and deleteDynamicSearchRule(uid) targeting dynamic-search-rules endpoints.
Tests
tests/search-rules.test.ts, tests/get_search.test.ts, tests/experimental-features.test.ts
Added end-to-end Vitest file exercising list/get/patch/delete flows for dynamic search rules. Adjusted an existing search test to check properties individually. Updated experimental features tests to include dynamicSearchRules.
Code Samples
.code-samples.meilisearch.yaml
Added code-sample mappings for listing, retrieving, patching, and deleting dynamic search rules.
Miscellaneous
src/task.ts
Simplified timeout callback in TaskClient.waitForTask (removed unnecessary void wrapper).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SDK as Meilisearch SDK
  participant Server as Meilisearch Server
  Client->>SDK: call getDynamicSearchRules(parameters)
  SDK->>Server: POST /dynamic-search-rules (body: parameters)
  Server-->>SDK: 200 { results: [...], total: N }
  SDK-->>Client: return results
Loading
sequenceDiagram
  participant Client
  participant SDK as Meilisearch SDK
  participant Server as Meilisearch Server
  Client->>SDK: call updateDynamicSearchRule(uid, rule)
  SDK->>Server: PATCH /dynamic-search-rules/{uid} (body: rule)
  Server-->>SDK: 200 { uid, actions, ... }
  SDK-->>Client: return updated rule
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through types and HTTP trails,
I pinned the docs where search prevails,
Tests ran, samples neatly penned,
v1.42 — a rabbit's friend,
Hop on, new rules are set to send! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes two out-of-scope changes: upgrading Meilisearch version from v1.40 to v1.42 in docker-compose.yml and tests.yml, and refactoring timeout logic in src/task.ts unrelated to dynamic search rules. Remove version upgrade changes and task.ts refactoring from this PR, or document them as necessary dependencies in the PR description. These should be separate PRs or justified as critical fixes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add dynamic search rules' directly and clearly summarizes the main objective of the PR, which is to implement support for the Dynamic Search Rules API.
Linked Issues check ✅ Passed All requirements from issue #2167 are met: four new API methods implemented [getDynamicSearchRules, getDynamicSearchRule, updateDynamicSearchRule, deleteDynamicSearchRule], comprehensive test coverage added, and code samples added to .code-samples.meilisearch.yaml with all required keys.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-dynamic-search-rules

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.

@Strift Strift force-pushed the feat/add-dynamic-search-rules branch from 63108f8 to 8579763 Compare April 14, 2026 08:21
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.97%. Comparing base (c162ca3) to head (3c7bf9c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2171      +/-   ##
==========================================
+ Coverage   97.95%   97.97%   +0.02%     
==========================================
  Files          14       14              
  Lines         635      642       +7     
  Branches      106      104       -2     
==========================================
+ Hits          622      629       +7     
  Misses         12       12              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Strift Strift added the enhancement New feature or request label Apr 15, 2026
@Strift Strift marked this pull request as ready for review April 15, 2026 08:41
@Strift Strift requested review from curquiza and flevi29 April 15, 2026 08:41
@Strift Strift enabled auto-merge April 15, 2026 08:41
Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/get_search.test.ts`:
- Around line 151-153: The test currently only checks that each key from
dataset[1] exists on hit, which is too permissive; update the assertion to
validate exact shape and values by using expect(hit).toMatchObject(dataset[1])
and also assert strict key count (e.g., compare Object.keys(hit).length ===
Object.keys(dataset[1]).length) so extra fields are caught; modify the block
that uses Object.keys(dataset[1]).forEach((key) =>
expect(hit).toHaveProperty(key)) to perform these two checks against dataset[1]
and the hit variable.

In `@tests/search-rules.test.ts`:
- Around line 27-30: The test is bypassing types because
RuntimeTogglableFeatures is missing dynamicSearchRules; add a field
dynamicSearchRules?: boolean | null to the RuntimeTogglableFeatures type in
src/types/experimental-features.ts so it matches other toggles, then update the
test to remove the unsafe "as unknown as" cast and use "satisfies
Parameters<Meilisearch['updateExperimentalFeatures']>[0]" for the
dynamicSearchRulesFeature object; reference the RuntimeTogglableFeatures type
and the updateExperimentalFeatures method to locate where to change types and
the failing call in tests (dynamicSearchRules,
masterClient.updateExperimentalFeatures).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3005fda-47b8-4231-bb5b-de28a22b5875

📥 Commits

Reviewing files that changed from the base of the PR and between c162ca3 and eaf33a1.

📒 Files selected for processing (9)
  • .code-samples.meilisearch.yaml
  • .github/workflows/tests.yml
  • docker-compose.yml
  • src/meilisearch.ts
  • src/task.ts
  • src/types/index.ts
  • src/types/search-rules.ts
  • tests/get_search.test.ts
  • tests/search-rules.test.ts

Comment thread tests/get_search.test.ts
Comment thread tests/search-rules.test.ts Outdated
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.41] Add support for Dynamic Search Rules

1 participant