Skip to content

Conversation

@joonseolee
Copy link
Contributor

@joonseolee joonseolee commented Aug 13, 2025

Pull Request

Related issue

Fixes #871

What does this PR do?

  • Adds a unit test to verify storing and retrieving the disableOnNumbers setting in TypoTolerance
  • Adds typo_tolerance_guide_5 code sample in .code-samples.meilisearch.yaml demonstrating how to enable disableOnNumbers

PR checklist

Please check if your PR fulfills the following requirements:

  • 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 an option to disable typo tolerance on numeric content, providing finer control over search behavior with numbers.
  • Documentation

    • Added a code sample demonstrating how to enable the "disable on numbers" typo-tolerance option.
  • Tests

    • Added integration tests verifying the option is false by default and true when enabled (note: duplicated test case included).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

Adds a new TypoTolerance field disableOnNumbers, a code sample typo_tolerance_guide_5 in .code-samples.meilisearch.yaml, and integration test methods in SettingsTest that update and verify disableOnNumbers via the SDK's typo tolerance settings.

Changes

Cohort / File(s) Summary
Model
src/main/java/com/meilisearch/sdk/model/TypoTolerance.java
Added protected Boolean disableOnNumbers field to TypoTolerance.
Integration tests
src/test/java/com/meilisearch/integration/SettingsTest.java
Added test method(s) testUpdateDisableOnNumbersTolerance() verifying update and retrieval of disableOnNumbers in typo tolerance settings. Note: the diff contains a duplicated identical test method.
Code samples
.code-samples.meilisearch.yaml
Added code-sample entry typo_tolerance_guide_5 demonstrating updateTypoTolerance with disableOnNumbers.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant SDK as SDK Client
    participant Model as TypoTolerance (SDK)
    participant Server as Meilisearch Server

    SDK->>Model: construct TypoTolerance { disableOnNumbers: true }
    SDK->>Server: updateTypoTolerance(index="movies", TypoTolerance)
    Server-->>SDK: 200 OK (settings queued/updated)
    SDK->>Server: getTypoTolerance(index="movies")
    Server-->>SDK: TypoTolerance { disableOnNumbers: true }
    note right of Server #DDEBF7: New field persisted and returned by server
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble code with curious paws,
A switch hushes numeric flaws.
Tests hop in to check the way,
Samples show the proper play.
🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 disableOnNumbers setting in TypoTolerance" is concise, accurately describes the primary change (adding the disableOnNumbers option to the TypoTolerance model and associated artifacts), and is clear for a teammate scanning PR history.
Linked Issues Check ✅ Passed The PR implements the linked issue #871 coding objectives: the TypoTolerance model gains a disableOnNumbers field, .code-samples.meilisearch.yaml includes typo_tolerance_guide_5, and integration tests exercise storing and retrieving the new setting, so the required API/model, sample, and tests are present (note the tests appear duplicated in the diff).
Out of Scope Changes Check ✅ Passed I found no changes outside the linked issue's scope: the diff only adds the disableOnNumbers field to the TypoTolerance model, a corresponding code sample entry, and tests to verify the setting; there are no unrelated files or feature changes introduced (aside from the duplicate test which is a quality issue but still within scope).
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56987a3 and 8a976a4.

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

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Copy link
Contributor

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

🧹 Nitpick comments (2)
.code-samples.meilisearch.yaml (1)

455-458: Docs sample looks good; minor consistency nit on index naming.

Most samples use "movies"/"books". If "1917" isn’t intentional to emphasize numeric terms, prefer staying consistent with other examples.

Apply this minimal change if consistency is preferred:

-  client.index("1917").updateTypoToleranceSettings(typoTolerance);
+  client.index("movies").updateTypoToleranceSettings(typoTolerance);
src/test/java/com/meilisearch/integration/SettingsTest.java (1)

903-919: Good coverage for disableOnNumbers; consider also asserting the toggle back to false.

The test validates default false and setting true. Adding a final toggle back to false ensures both directions of the update work.

Apply this diff to extend the test:

     TypoTolerance updatedTypoToleranceDisableOnNumbers = index.getTypoToleranceSettings();

     assertThat(updatedTypoToleranceDefault.isDisableOnNumbers(), is(equalTo(false)));
     assertThat(updatedTypoToleranceDisableOnNumbers.isDisableOnNumbers(), is(equalTo(true)));
+
+    // Toggle back to false and assert
+    TypoTolerance newTypoToleranceBackToFalse = new TypoTolerance().setDisableOnNumbers(false);
+    index.waitForTask(index.updateTypoToleranceSettings(newTypoToleranceBackToFalse).getTaskUid());
+    TypoTolerance updatedTypoToleranceBackToFalse = index.getTypoToleranceSettings();
+    assertThat(updatedTypoToleranceBackToFalse.isDisableOnNumbers(), is(equalTo(false)));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34e6053 and fbc9852.

📒 Files selected for processing (3)
  • .code-samples.meilisearch.yaml (1 hunks)
  • src/main/java/com/meilisearch/sdk/model/TypoTolerance.java (1 hunks)
  • src/test/java/com/meilisearch/integration/SettingsTest.java (1 hunks)

@joonseolee joonseolee force-pushed the v1.15/add-disable-on-numbers-option branch from 8e62e9b to 56987a3 Compare September 12, 2025 01:09
Copy link
Contributor

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

🧹 Nitpick comments (1)
src/test/java/com/meilisearch/integration/SettingsTest.java (1)

903-919: Drop the no-op update; fetch baseline directly to reduce runtime and ambiguity.

Updating with an empty TypoTolerance ({}) is unnecessary for a fresh index and can be misleading. Read the baseline first, then toggle to true.

@@
-        TypoTolerance newTypoTolerance = new TypoTolerance();
-        index.waitForTask(index.updateTypoToleranceSettings(newTypoTolerance).getTaskUid());
-        TypoTolerance updatedTypoToleranceDefault = index.getTypoToleranceSettings();
+        TypoTolerance updatedTypoToleranceDefault = index.getTypoToleranceSettings();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbc9852 and 8e62e9b.

📒 Files selected for processing (2)
  • src/main/java/com/meilisearch/sdk/model/TypoTolerance.java (1 hunks)
  • src/test/java/com/meilisearch/integration/SettingsTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/meilisearch/sdk/model/TypoTolerance.java

@joonseolee
Copy link
Contributor Author

@Strift

Could you check it please? :)

Copy link
Contributor

@Strift Strift left a comment

Choose a reason for hiding this comment

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

Hi @joonseolee and thanks for your contribution 🙌

typo_tolerance_guide_5: |-
TypoTolerance typoTolerance = new TypoTolerance();
typoTolerance.setDisableOnNumbers(true);
client.index("1917").updateTypoToleranceSettings(typoTolerance);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
client.index("1917").updateTypoToleranceSettings(typoTolerance);
client.index("movies").updateTypoToleranceSettings(typoTolerance);

Comment on lines 908 to 910
TypoTolerance newTypoTolerance = new TypoTolerance();
index.waitForTask(index.updateTypoToleranceSettings(newTypoTolerance).getTaskUid());
TypoTolerance updatedTypoToleranceDefault = index.getTypoToleranceSettings();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can simplify by simply fetching the initial typo tolerance settings, e.g. simply

Index index = createIndex("testUpdateDisableOnNumbers");
TypoTolerance defaultTypoTolerance = index.getTypoToleranceSettings();

Initializing an empty index with default settings can be confusing

Comment on lines 918 to 919
assertThat(updatedTypoToleranceDefault.getDisableOnNumbers(), is(equalTo(false)));
assertThat(updatedTypoToleranceDisableOnNumbers.getDisableOnNumbers(), is(equalTo(true)));
Copy link
Contributor

Choose a reason for hiding this comment

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

After simplifying above, we can make this a bit clearer with two assertions

  • one on the defaultTypoTolerance
  • one on the updatedTypoTolerance

@joonseolee joonseolee force-pushed the v1.15/add-disable-on-numbers-option branch from 56987a3 to 8a976a4 Compare September 13, 2025 04:47
@joonseolee
Copy link
Contributor Author

@Strift

I’ve made the changes you mentioned and updated them.
Could you check again?

Copy link
Contributor

@Strift Strift left a comment

Choose a reason for hiding this comment

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

Thanks! Let's get this merged 🙌

@Strift Strift merged commit bc0d1b5 into meilisearch:main Sep 16, 2025
3 checks passed
@Strift Strift added the enhancement New feature or request label Sep 16, 2025
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.

[v1.15] Add disableOnNumbers to typo tolerance settings

2 participants