Skip to content

Add dynamic search rules API support#982

Open
Fayupable wants to merge 4 commits into
meilisearch:mainfrom
Fayupable:main
Open

Add dynamic search rules API support#982
Fayupable wants to merge 4 commits into
meilisearch:mainfrom
Fayupable:main

Conversation

@Fayupable

@Fayupable Fayupable commented Jul 21, 2026

Copy link
Copy Markdown

Related issue

Fixes #981

What does this PR do?

  • Adds support for the experimental Dynamic Search Rules API introduced in Meilisearch v1.50.0
  • client.listDynamicSearchRules(query)POST /dynamic-search-rules (list, with pagination/filtering via DynamicSearchRulesQuery)
  • client.getDynamicSearchRule(uid)GET /dynamic-search-rules/{uid}
  • client.updateDynamicSearchRule(uid, rule)PATCH /dynamic-search-rules/{uid} (upsert, returns TaskInfo)
  • client.deleteDynamicSearchRule(uid)DELETE /dynamic-search-rules/{uid} (returns TaskInfo)
  • Adds new model classes DynamicSearchRule and DynamicSearchRulesQuery
  • Adds integration tests in DynamicSearchRulesTest, covering list, get, upsert (create + update), delete, and enabling the dynamicSearchRules experimental feature flag in test setup
  • Adds code samples to .code-samples.meilisearch.yaml: list_dynamic_search_rules_1, get_dynamic_search_rule_1, patch_dynamic_search_rule_1, delete_dynamic_search_rule_1, matching the equivalent samples in the documentation repo

Note: this is an experimental feature and I wasn't able to run the full integration test suite locally against a v1.50.0 instance — happy to address anything CI or review turns up.

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.
    • Yes — I used Claude (Anthropic) as a coding assistant to draft the handler/model classes and integration tests, following the existing patterns in WebHooksHandler/WebhooksTest. I reviewed and wrote all the code myself in github.dev.
  • 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 Java client support for Dynamic Search Rules.
    • Manage rules with metadata (UID, description, priority, active) plus structured conditions and actions.
    • List, retrieve, update, and delete rules, with pagination and filtering via a query object.
  • Documentation
    • Added Dynamic Search Rules Java code samples: list all rules, get by UID, update (patch), and delete by UID.
  • Tests
    • Added integration tests for rule update, retrieval, listing, and deletion (with the required experimental feature enabled).

Implement list, get, upsert (PATCH), and delete endpoints for the
experimental dynamic search rules feature introduced in Meilisearch
v1.50.0, plus integration tests and code samples.
@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: 44c526b3-57d6-426b-962b-1c6fa3791d3c

📥 Commits

Reviewing files that changed from the base of the PR and between c41b8c9 and d534011.

📒 Files selected for processing (1)
  • .code-samples.meilisearch.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .code-samples.meilisearch.yaml

📝 Walkthrough

Walkthrough

Dynamic Search Rules support is added to the Java SDK through serializable models, client and HTTP handler methods, integration tests, and documentation examples for listing, retrieval, upsert, and deletion.

Changes

Dynamic Search Rules

Layer / File(s) Summary
Rule data contracts
src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java, src/main/java/com/meilisearch/sdk/model/DynamicSearchRulesQuery.java
Adds serializable models for rule metadata, conditions, actions, pagination, and filtering.
Client and endpoint integration
src/main/java/com/meilisearch/sdk/DynamicSearchRulesHandler.java, src/main/java/com/meilisearch/sdk/Client.java
Adds list, get, update, and delete operations for the /dynamic-search-rules endpoints.
Integration coverage and examples
src/test/java/com/meilisearch/integration/DynamicSearchRulesTest.java, .code-samples.meilisearch.yaml
Enables the experimental feature, tests all operations, and adds Java usage examples.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant DynamicSearchRulesHandler
  participant MeilisearchAPI
  Client->>DynamicSearchRulesHandler: listDynamicSearchRules(query)
  DynamicSearchRulesHandler->>MeilisearchAPI: POST /dynamic-search-rules
  MeilisearchAPI-->>DynamicSearchRulesHandler: Results<DynamicSearchRule>
  Client->>DynamicSearchRulesHandler: updateDynamicSearchRule(uid, rule)
  DynamicSearchRulesHandler->>MeilisearchAPI: PATCH /dynamic-search-rules/{uid}
  MeilisearchAPI-->>DynamicSearchRulesHandler: TaskInfo
  Client->>DynamicSearchRulesHandler: deleteDynamicSearchRule(uid)
  DynamicSearchRulesHandler->>MeilisearchAPI: DELETE /dynamic-search-rules/{uid}
  MeilisearchAPI-->>DynamicSearchRulesHandler: TaskInfo
Loading

Possibly related issues

  • meilisearch/meilisearch-ruby#708 — Covers equivalent Dynamic Search Rules API support.
  • meilisearch/meilisearch-swift#528 — Covers equivalent Dynamic Search Rules API support.
  • meilisearch/meilisearch-dart#495 — Covers equivalent Dynamic Search Rules API support.

Poem

A bunny found four rules in a row,
List, fetch, patch, then off they go.
With tasks that hop and models bright,
Tests guard each endpoint day and night.
“Search shall pin!” the rabbit sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Dynamic Search Rules API support.
Linked Issues check ✅ Passed The PR appears to cover the requested list, get, upsert, and delete endpoints, plus models, tests, pagination/filtering, task handling, and code samples.
Out of Scope Changes check ✅ Passed The changes are focused on Dynamic Search Rules API support, tests, models, and samples, with no obvious unrelated additions.
✨ 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 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/com/meilisearch/sdk/Client.java (1)

636-639: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Provide a parameterless overload for convenience.

Other listing methods in Client (such as getIndexes() and getTasks()) provide an overloaded parameterless method that executes the request using default pagination parameters. Consider adding a similar overload here for consistency and developer convenience.

♻️ Proposed refactor
     public Results<DynamicSearchRule> listDynamicSearchRules(DynamicSearchRulesQuery query)
             throws MeilisearchException {
         return this.dynamicSearchRulesHandler.listDynamicSearchRules(query);
     }
+
+    /**
+     * Get a list of all dynamic search rules using default pagination parameters.
+     *
+     * `@return` Results containing a list of DynamicSearchRule instances.
+     * `@throws` MeilisearchException If an error occurs.
+     */
+    public Results<DynamicSearchRule> listDynamicSearchRules() throws MeilisearchException {
+        return this.dynamicSearchRulesHandler.listDynamicSearchRules(new DynamicSearchRulesQuery());
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/meilisearch/sdk/Client.java` around lines 636 - 639, Add a
parameterless listDynamicSearchRules() overload to Client alongside the existing
query-based method. Have it delegate to listDynamicSearchRules with the
established default pagination/query parameters, matching the pattern used by
getIndexes() and getTasks().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java`:
- Around line 23-36: Add a Jackson-compatible no-argument constructor to
DynamicSearchRule, preserving the existing all-arguments constructor and field
assignments. Ensure Jackson can instantiate the class from API JSON without
relying on parameter-name modules or setters.

---

Nitpick comments:
In `@src/main/java/com/meilisearch/sdk/Client.java`:
- Around line 636-639: Add a parameterless listDynamicSearchRules() overload to
Client alongside the existing query-based method. Have it delegate to
listDynamicSearchRules with the established default pagination/query parameters,
matching the pattern used by getIndexes() and getTasks().
🪄 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: ae97d2ff-57f5-4b02-bb2a-fe5ec1e92cdc

📥 Commits

Reviewing files that changed from the base of the PR and between 4664538 and ec78f3c.

📒 Files selected for processing (6)
  • .code-samples.meilisearch.yaml
  • src/main/java/com/meilisearch/sdk/Client.java
  • src/main/java/com/meilisearch/sdk/DynamicSearchRulesHandler.java
  • src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java
  • src/main/java/com/meilisearch/sdk/model/DynamicSearchRulesQuery.java
  • src/test/java/com/meilisearch/integration/DynamicSearchRulesTest.java

Comment thread src/main/java/com/meilisearch/sdk/model/DynamicSearchRule.java
@Strift Strift added the enhancement New feature or request label Jul 22, 2026

@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.

Hey, thanks for your PR!

The CI is not passing. I suggest running linter + formatter + tests locally before requesting another review 🙏

@Fayupable

Copy link
Copy Markdown
Author

This is the Docker command I ran to test against JDK 17, since I don't have JDK 17 installed locally: docker run --rm -v "$PWD":/workspace -w /workspace eclipse-temurin:17-jdk ./gradlew spotlessCheck compileTestJava
image

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.50.0] Add Dynamic Search Rules (experimental)

2 participants