Skip to content

Add disableOnNumbers to typo tolerance settings #1951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2025

Conversation

Strift
Copy link
Collaborator

@Strift Strift commented May 23, 2025

Pull Request

This PR updates the typo tolerance settings to allow deactivating typo tolerance on high entropy words.

Related engine issue: meilisearch/meilisearch#5344

What does this PR do?

  • Update typo tolerance settings to accept and return disableOnNumbers: bool field
  • Update tests to use toMatchSnapshot() instead of manually testing against a "default settings" object

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 a new option to control typo tolerance on numeric values.
  • Tests

    • Updated tests to use snapshot testing for typo tolerance settings.
    • Added test coverage for the new numeric typo tolerance option.

Copy link

coderabbitai bot commented May 23, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new optional property, disableOnNumbers, was added to the TypoTolerance type definition. Corresponding tests were updated to use snapshot testing for default settings and to include the new property in update scenarios. No changes were made to the exports or public interfaces beyond the type update.

Changes

File(s) Change Summary
src/types/types.ts Added optional `disableOnNumbers?: boolean
tests/typo_tolerance.test.ts Switched default checks to snapshot testing; added disableOnNumbers: true to update test object.

Poem

A new flag for numbers, a toggle so neat,
Typo tolerance now skips numeric defeat.
Snapshots ensure our settings stay right,
With tests updated, all through the night.
Hopping ahead, our code feels complete!
🐇✨


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Strift Strift requested a review from Copilot May 23, 2025 05:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the typo tolerance settings to include a new boolean field, disableOnNumbers, allowing the deactivation of typo tolerance on high entropy words. Key changes include:

  • Updating tests/typo_tolerance.test.ts to use snapshot testing and validate the new disableOnNumbers field.
  • Refreshing related snapshot files (tests/snapshots/typo_tolerance.test.ts.snap and tests/snapshots/settings.test.ts.snap) with the new property.
  • Updating the type definition in src/types/types.ts to include disableOnNumbers.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/typo_tolerance.test.ts Removed defaultTypoTolerance variable and switched to snapshots with the new disableOnNumbers property.
tests/snapshots/typo_tolerance.test.ts.snap Updated snapshots to reflect the new disableOnNumbers field.
tests/snapshots/settings.test.ts.snap Updated snapshots to include disableOnNumbers in settings tests.
src/types/types.ts Added the disableOnNumbers field to the TypoTolerance type.

@Strift
Copy link
Collaborator Author

Strift commented May 23, 2025

@coderabbitai review

Copy link

coderabbitai bot commented May 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@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)
tests/typo_tolerance.test.ts (1)

45-45: Proper test coverage for the new property.

The addition of disableOnNumbers: true to the test object appropriately validates the new functionality. The test correctly verifies that the property can be set and retrieved.

Consider adding test cases for the other possible values to enhance coverage:

     test(`${permission} key: Update typo tolerance settings`, async () => {
       const client = await getClient(permission);
       const newTypoTolerance = {
         enabled: false,
         minWordSizeForTypos: {
           oneTypo: 1,
           twoTypos: 2,
         },
         disableOnWords: ["title"],
         disableOnAttributes: ["hello"],
         disableOnNumbers: true,
       };
       await client
         .index(index.uid)
         .updateTypoTolerance(newTypoTolerance)
         .waitTask();

       const response = await client.index(index.uid).getTypoTolerance();
       expect(response).toEqual(newTypoTolerance);
     });
+
+    test(`${permission} key: Update typo tolerance with disableOnNumbers false`, async () => {
+      const client = await getClient(permission);
+      const newTypoTolerance = {
+        disableOnNumbers: false,
+      };
+      await client
+        .index(index.uid)
+        .updateTypoTolerance(newTypoTolerance)
+        .waitTask();
+
+      const response = await client.index(index.uid).getTypoTolerance();
+      expect(response.disableOnNumbers).toBe(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 0a2201b and eb37272.

⛔ Files ignored due to path filters (2)
  • tests/__snapshots__/settings.test.ts.snap is excluded by !**/*.snap
  • tests/__snapshots__/typo_tolerance.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/types/types.ts (1 hunks)
  • tests/typo_tolerance.test.ts (4 hunks)
🔇 Additional comments (2)
src/types/types.ts (1)

526-526: LGTM! Consistent implementation with existing patterns.

The addition of disableOnNumbers property follows the established pattern for typo tolerance options. The type definition is correct (boolean | null), the naming is consistent with similar properties (disableOnAttributes, disableOnWords), and it's properly marked as optional.

tests/typo_tolerance.test.ts (1)

32-32: Good improvement: Switch to snapshot testing for default values.

Using toMatchSnapshot() instead of hardcoded expected values makes the tests more maintainable and flexible as the API evolves. This approach prevents brittle tests that break when new properties are added to the default response.

Also applies to: 62-62, 71-71

@Strift Strift requested a review from flevi29 May 23, 2025 05:43
@Strift Strift self-assigned this May 23, 2025
@Strift Strift added the enhancement New feature or request label May 23, 2025
@Strift Strift changed the title Update typo tolerance settings to handle disableOnNumbers Add disableOnNumbers to typo tolerance settings May 23, 2025
@Strift Strift merged commit a45688d into bump-meilisearch-v1.15.0 May 28, 2025
8 checks passed
@Strift Strift deleted the feat/update-typo-tolerance-settings branch May 28, 2025 04:54
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.

2 participants