Skip to content

implement rankingScoreThreshold search query parameter #436

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

memishood
Copy link
Contributor

@memishood memishood commented Aug 2, 2025

Pull Request

Related issue

Fixes #386

What does this PR do?

  • implemented rankingScoreThreshold search parameter

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 support for filtering search results by a ranking score threshold parameter.
  • Tests
    • Added tests to ensure search results meet the specified ranking score threshold.
  • Documentation
    • Included new code samples demonstrating the use of the ranking score threshold in search queries.

Copy link

coderabbitai bot commented Aug 2, 2025

Walkthrough

The changes introduce support for a new optional rankingScoreThreshold parameter in the search query classes. This parameter is added to constructors, copy methods, and serialization logic. A new test verifies its effect on search results. The .code-samples.meilisearch.yaml and code sample tests are updated to include usage examples. No other logic or control flow modifications are present.

Changes

Cohort / File(s) Change Summary
IndexSearchQuery parameter support
lib/src/query_parameters/index_search_query.dart
Added optional rankingScoreThreshold parameter to the IndexSearchQuery constructor and copyWith method. Integrated into internal state copying and passed to the superclass.
SearchQuery parameter and serialization
lib/src/query_parameters/search_query.dart
Introduced nullable rankingScoreThreshold field with version annotation. Updated constructor, buildMap() serialization, and copyWith() method to handle this parameter.
Integration test for rankingScoreThreshold
test/search_test.dart
Added a test case in the Books group to verify that rankingScoreThreshold filters search results as expected.
Code sample additions
.code-samples.meilisearch.yaml, test/code_samples.dart
Added a new code sample demonstrating rankingScoreThreshold usage in search queries for the "movies" index, with corresponding test snippet included.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Test Case
  participant Client as Search Client
  participant Query as SearchQuery
  participant Server as Meilisearch Server

  Test->>Client: Initiate search with SearchQuery (rankingScoreThreshold=0.9)
  Client->>Query: Build query map (includes rankingScoreThreshold)
  Client->>Server: Send search request with parameters
  Server-->>Client: Return filtered results (rankingScore >= 0.9)
  Client-->>Test: Return search results
  Test->>Test: Assert all hits have rankingScore >= 0.9
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Support rankingScoreThreshold search parameter in the library (#386)
Add integration tests for rankingScoreThreshold (#386)
Update .code-samples.meilisearch.yaml with reference example (#386)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Poem

A hop, a skip, a ranking score,
Now queries filter even more!
Thresholds set, results refined,
The search is sharp, the code aligned.
With every test, this bunny cheers—
For features fresh in new frontiers! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 b1bf345 and b3113f7.

📒 Files selected for processing (5)
  • .code-samples.meilisearch.yaml (1 hunks)
  • lib/src/query_parameters/index_search_query.dart (3 hunks)
  • lib/src/query_parameters/search_query.dart (5 hunks)
  • test/code_samples.dart (1 hunks)
  • test/search_test.dart (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • test/code_samples.dart
  • .code-samples.meilisearch.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/search_test.dart
  • lib/src/query_parameters/search_query.dart
  • lib/src/query_parameters/index_search_query.dart
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 generate unit tests to generate unit tests for 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.

Copy link

codecov bot commented Aug 2, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.22%. Comparing base (d728b29) to head (b3113f7).
⚠️ Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/query_parameters/index_search_query.dart 0.00% 1 Missing ⚠️
lib/src/query_parameters/search_query.dart 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #436      +/-   ##
==========================================
+ Coverage   75.19%   76.22%   +1.03%     
==========================================
  Files          60       58       -2     
  Lines        1524     1506      -18     
==========================================
+ Hits         1146     1148       +2     
+ Misses        378      358      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@memishood memishood force-pushed the feat/ranking-score-threshold branch from b1bf345 to b3113f7 Compare August 2, 2025 21:29
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.

[v1.9] Support rankingScoreThreshold search parameter
1 participant