Skip to content

feat: add Dynamic Search Rules API support#798

Open
hfl0506 wants to merge 2 commits into
meilisearch:mainfrom
hfl0506:feat/dynamic-search-rules
Open

feat: add Dynamic Search Rules API support#798
hfl0506 wants to merge 2 commits into
meilisearch:mainfrom
hfl0506:feat/dynamic-search-rules

Conversation

@hfl0506

@hfl0506 hfl0506 commented Jul 21, 2026

Copy link
Copy Markdown

Pull Request

Related issue

Fixes #797

What does this PR do?

  • Added Dynamic Search Rules models, conditions, actions, selectors, filters, and
    pagination types.

  • Added get_dynamic_search_rules for listing and filtering rules.

  • Added get_dynamic_search_rule for retrieving a rule by UID.

  • Added update_dynamic_search_rule for creating/updating rules via async tasks.

  • Added delete_dynamic_search_rule with async-task handling.

  • Added dynamicSearchRules experimental-feature support.

  • Added dsrUpdate and dsrClear task parsing.

  • Added tests for list, get, create, update, delete, filtering, pagination, and tasks.

  • Added all four requested documentation code samples.

  • Updated two existing tests for Meilisearch v1.50 and current uuid.

  • Full result: 198 tests and 201 doctests passing.

Test Steps

docker run --rm -d \
  --name meilisearch-sdk-test \
  -p 7700:7700 \
  getmeili/meilisearch-enterprise:v1.50.0 \
  meilisearch --master-key=masterKey --no-analytics

# Wait until ready:

curl -sf http://localhost:7700/health

# Run the full integration suite:

cargo test --verbose

# Run only the relevant tests:

cargo test search_rules::tests --lib -- --nocapture
cargo test features::tests::test_experimental_features --lib -- --nocapture
cargo test search::tests::test_query_facet_distribution --lib -- --nocapture

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 support for managing dynamic search rules, including listing, retrieving, updating, and deleting rules.
    • Added configuration support for enabling dynamic search rules as an experimental feature.
    • Added examples covering dynamic rule management, conditions, time windows, and result pinning.
  • Bug Fixes

    • Improved handling of dynamic search rule task details.
    • Updated error validation expectations and expanded facet-search test coverage.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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: c870edb4-cf0b-4949-bc54-cb3257c243de

📥 Commits

Reviewing files that changed from the base of the PR and between 60213d5 and c846a75.

📒 Files selected for processing (8)
  • .code-samples.meilisearch.yaml
  • src/client.rs
  • src/errors.rs
  • src/features.rs
  • src/lib.rs
  • src/search.rs
  • src/search_rules.rs
  • src/tasks.rs

📝 Walkthrough

Walkthrough

Adds experimental dynamic search rules support with typed Rust models, four client endpoints, feature gating, asynchronous task handling, integration tests, and documentation examples. Existing facet-search and UUID error-message tests are also updated.

Changes

Dynamic search rules

Layer / File(s) Summary
Rule models and API contracts
src/lib.rs, src/search_rules.rs
Defines query, filter, paginated result, rule, condition, action, selector, and partial-update types with serialization helpers and endpoint tests.
Client endpoint integration
src/client.rs, src/tasks.rs
Adds list, get, patch/upsert, and delete methods, with task response handling for rule updates and deletions.
Feature gating and examples
src/features.rs, .code-samples.meilisearch.yaml
Adds the experimental feature flag and examples for all four dynamic search rule operations.

Test compatibility updates

Layer / File(s) Summary
Existing test adjustments
src/search.rs, src/errors.rs
Configures advanced facet-search settings in a facet distribution test and updates the expected UUID parsing message.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

  • meilisearch-java issue 981 — Covers equivalent Dynamic Search Rules SDK support.
  • meilisearch-python issue 1264 — Covers equivalent Dynamic Search Rules SDK support.
  • meilisearch-ruby issue 708 — Covers equivalent Dynamic Search Rules SDK support.
  • meilisearch-swift issue 528 — Covers equivalent Dynamic Search Rules SDK support.

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant Client
  participant Meilisearch
  participant TaskResponse
  Application->>Client: Configure dynamic_search_rules
  Client->>Meilisearch: PATCH /experimental-features
  Application->>Client: List, get, update, or delete a rule
  Client->>Meilisearch: Request dynamic search rule endpoint
  Meilisearch-->>Client: Rules or asynchronous task
  Client->>TaskResponse: Deserialize task type
  TaskResponse-->>Application: TaskInfo or rule result
Loading

Poem

A bunny hops through rules so bright,
Pins a result in perfect sight.
Queries, time, and actions align,
Tasks return with ears held high.
Four new paths now softly bloom—
Search rules dance around the room!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding Dynamic Search Rules API support.
Linked Issues check ✅ Passed The PR adds all four endpoints, models, experimental feature support, task handling, tests, and documentation samples required by #797.
Out of Scope Changes check ✅ Passed The extra test compatibility updates in errors.rs and search.rs align with the PR's stated v1.50/test-suite follow-up work and are not unrelated.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
✨ 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.

@hfl0506
hfl0506 marked this pull request as ready for review July 21, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Meilisearch v1.50.0] Add Dynamic Search Rules (experimental)

1 participant