Skip to content

feat: add filter condition to dynamic search rules - #987

Merged
Strift merged 2 commits into
meilisearch:mainfrom
zshs000:feat/986-dynamic-search-rule-filter
Jul 29, 2026
Merged

feat: add filter condition to dynamic search rules#987
Strift merged 2 commits into
meilisearch:mainfrom
zshs000:feat/986-dynamic-search-rule-filter

Conversation

@zshs000

@zshs000 zshs000 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Related issue

Fixes #986

What does this PR do?

  • Update DynamicSearchRule.conditions type from List<Map<String, Object>> to Map<String, Object> to align with Meilisearch v1.50.0 API changes
  • Add support for filter condition in dynamic search rules (Meilisearch v1.51.0)
  • Add lastUpdatedAt field to DynamicSearchRule
  • Update integration tests to cover filter condition create/update flows
  • Add unit tests for filter condition serialization and lastUpdatedAt deserialization

AI usage disclosure: Test cases in DynamicSearchRulesTest.java and DynamicSearchRuleTest.java were generated with Codex and then manually reviewed and adjusted.

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
    • Dynamic search rules now support structured conditions, including nested query/time and filter values.
    • Exposes a rule’s lastUpdatedAt timestamp.
  • Improvements
    • Dynamic search rules now preserve condition payloads correctly across create, update, retrieve, and list.
    • JSON serialization/deserialization was enhanced to match the new conditions structure.
    • Renamed priority to precedence.
    • Updated dynamic rule examples to the new conditions format.

@coderabbitai

coderabbitai Bot commented Jul 28, 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 Plus

Run ID: 248b702e-f4c5-4d7d-b2eb-1b44f9310ec9

📥 Commits

Reviewing files that changed from the base of the PR and between d283628 and 2c0691c.

📒 Files selected for processing (4)
  • .code-samples.meilisearch.yaml
  • src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java
  • src/test/java/com/meilisearch/integration/DynamicSearchRulesTest.java
  • src/test/java/com/meilisearch/sdk/model/DynamicSearchRuleTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/test/java/com/meilisearch/sdk/model/DynamicSearchRuleTest.java
  • src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java
  • src/test/java/com/meilisearch/integration/DynamicSearchRulesTest.java

📝 Walkthrough

Walkthrough

DynamicSearchRule now accepts map-based conditions, exposes lastUpdatedAt, and uses precedence. Examples and tests cover filter-condition JSON handling and create/update responses.

Changes

Dynamic Search Rule support

Layer / File(s) Summary
Update rule model contract
src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java, .code-samples.meilisearch.yaml
conditions uses nested maps, the constructor accepts the updated shape, priority is renamed to precedence, and lastUpdatedAt is exposed.
Validate filter conditions and timestamps
src/test/java/com/meilisearch/sdk/model/DynamicSearchRuleTest.java, src/test/java/com/meilisearch/integration/DynamicSearchRulesTest.java
Tests cover JSON serialization/deserialization, filter values during create and update, precedence, and returned timestamps.

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

Possibly related issues

  • meilisearch/meilisearch-php issue 935 — Covers the same filter-condition and lastUpdatedAt objective.
  • meilisearch/meilisearch-js issue 2211 — Adds equivalent Dynamic Search Rule support.
  • meilisearch/meilisearch-python issue 1267 — Covers the same fields and operations.
  • meilisearch/meilisearch-ruby issue 709 — Implements equivalent response support.
  • meilisearch/meilisearch-rust issue 800 — Covers equivalent support with tests.
  • meilisearch/meilisearch-go issue 805 — Adds the same Dynamic Search Rule fields.
  • meilisearch/meilisearch-swift issue 530 — Adds equivalent filter and timestamp support.
  • meilisearch/meilisearch-dart issue 498 — Covers the same Dynamic Search Rule changes.

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant API
  participant Task
  Test->>API: Create rule with red filter
  API->>Task: Process create
  Task-->>API: Completed
  API-->>Test: Rule with conditions and lastUpdatedAt
  Test->>API: Update rule with blue filter
  API->>Task: Process update
  Task-->>API: Completed
  API-->>Test: Updated rule with conditions and lastUpdatedAt
Loading

Suggested labels: enhancement

Suggested reviewers: strift

Poem

I’m a bunny with filters, hopping bright,
Red turns blue in a rule overnight.
Maps hold conditions, timestamps shine,
JSON curls neatly in every line.
Hop, hop—DynamicSearchRules align!

🚥 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 is concise and directly reflects the main change: adding filter-condition support to dynamic search rules.
Linked Issues check ✅ Passed The PR adds filter-condition support, lastUpdatedAt handling, and tests for creation, updates, and response parsing as requested.
Out of Scope Changes check ✅ Passed The remaining changes, including the precedence rename and sample update, are consistent with the dynamic search rule API update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 28, 2026
Comment thread src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java Outdated

@Strift Strift left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @zshs000 and thanks for your contribution.

Just a few things before we can merge:

  • See review comments
  • Update .code-samples.meilisearch.yaml: patch_dynamic_search_rule_1 sample must use the new Map<String, Object> format for conditions

- Rename dynamic search rule priority to precedence and update tests
- Update the dynamic search rule code sample to use Map conditions
@zshs000
zshs000 requested a review from Strift July 28, 2026 15:43
@zshs000

zshs000 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Strift, I’ve addressed the requested changes:

  • Renamed priority to precedence and updated the related tests
  • Updated patch_dynamic_search_rule_1 in .code-samples.meilisearch.yaml to use the new Map<String, Object>
    format for conditions

The changes have been pushed. Could you please take another look when you have time? Thanks!

@Strift Strift left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the follow-up 🙌 LGTM!

@Strift
Strift added this pull request to the merge queue Jul 29, 2026
Merged via the queue into meilisearch:main with commit 740d3f6 Jul 29, 2026
3 checks passed
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.51.0] Add filter condition to Dynamic Search Rules

2 participants