Skip to content

Conversation

@kumarUjjawal
Copy link
Contributor

@kumarUjjawal kumarUjjawal commented Nov 3, 2025

Pull Request

Related issue

Fixes #664

What does this PR do?

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
    • Results now include a flag indicating whether facet counts are exact or estimated, so callers can know when displayed facet totals are definitive.
    • Added an optional query setting and a builder-style method to request exhaustive (exact) facet counts when performing searches, giving users control over accuracy vs. performance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

Added optional exhaustive facet counting: SearchQuery can request exhaustive facet counts via exhaustiveFacetCount, and SearchResults exposes the server's exhaustiveFacetCount in exhaustive_facet_count: Option<bool>; a builder method sets the query field and SearchQuery::new initializes it to None.

Changes

Cohort / File(s) Summary
Search API — exhaustive facet flag
src/search.rs
Added pub exhaustive_facet_count: Option<bool> to SearchQuery<'a, Http> (serialized as exhaustiveFacetCount) and initialized it to None in SearchQuery::new(). Added builder pub fn with_exhaustive_facet_count<'b>(&'b mut self, exhaustive: bool) -> &'b mut SearchQuery<'a, Http> to set the flag. Added pub exhaustive_facet_count: Option<bool> to SearchResults<T> to surface the response field.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client code
    participant Builder as SearchQuery builder
    participant HTTP as HTTP layer
    participant Server as Meilisearch server

    rect rgb(240,248,255)
    Client->>Builder: create SearchQuery
    Builder->>Builder: with_exhaustive_facet_count(true)
    end

    rect rgb(245,255,240)
    Builder->>HTTP: serialize query (includes exhaustiveFacetCount)
    HTTP->>Server: POST /search { ..., "exhaustiveFacetCount": true }
    Server-->>HTTP: 200 OK { ..., "exhaustiveFacetCount": true, "facetsDistribution": {...} }
    HTTP-->>Client: deserialize -> SearchResults.exhaustive_facet_count = Some(true)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single-file change with consistent pattern.
  • Review focus: correct serde rename to exhaustiveFacetCount, builder signature/borrow lifetimes, and that SearchResults deserializes the response field.

Possibly related PRs

Poem

🐰
I hopped through queries, keen and neat,
Toggling counts with eager feet.
Now facets tell their truth at last,
No guesses left from records past.
I nibble code — exactness sweet. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Add exhaustive facet search" is concise and clearly describes the main change introduced in this PR. It directly aligns with the primary objective of implementing support for exhaustive facet count functionality as part of the Meilisearch v1.14 update. The title is specific enough that a teammate reviewing the commit history would understand the feature being added, and it accurately reflects the code changes that introduce the exhaustive_facet_count field and associated builder method to the search query and results structures.
Linked Issues Check ✅ Passed The pull request successfully implements the requirement stated in linked issue #664 to "Update the search method to handle the exhaustiveFacetCount parameter." The implementation adds the exhaustive_facet_count field to both the SearchQuery struct (allowing clients to request exhaustive facet counts) and the SearchResults struct (allowing responses to indicate whether counts are exhaustive). The builder method with_exhaustive_facet_count provides a convenient API for setting this parameter, and the serialization is properly configured to use the camelCase name exhaustiveFacetCount as expected by the Meilisearch API. All coding requirements from the linked issue are met.
Out of Scope Changes Check ✅ Passed All changes in this pull request are directly scoped to implementing exhaustive facet search support as defined in linked issue #664. The modifications are focused exclusively on adding the exhaustiveFacetCount parameter handling through struct fields, initialization updates, and builder method implementation. No unrelated changes, refactoring, or functionality outside the stated objective have been introduced. The changeset is minimal and purposeful, containing only what is necessary to support the new feature.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

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: 5

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e90a3c2 and 1036295.

📒 Files selected for processing (1)
  • src/search.rs (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
Repo: meilisearch/meilisearch-rust PR: 625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.

Applied to files:

  • src/search.rs

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 88.09524% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.13%. Comparing base (e90a3c2) to head (53a95b7).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/search.rs 88.09% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #726      +/-   ##
==========================================
- Coverage   86.18%   86.13%   -0.06%     
==========================================
  Files          20       20              
  Lines        6263     6305      +42     
==========================================
+ Hits         5398     5431      +33     
- Misses        865      874       +9     

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

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/search.rs (1)

1992-2026: Strengthen the test assertion to verify the actual value.

The test correctly handles forward compatibility by accepting BadRequest errors from servers that don't support this field yet. However, when the field is present, the test only verifies it's Some(...) without checking the actual boolean value.

Apply this diff to verify the returned value matches the request:

         match res {
             Ok(results) => {
-                assert!(results.exhaustive_facet_count.is_some());
+                assert_eq!(results.exhaustive_facet_count, Some(true), 
+                    "Expected exhaustive_facet_count to be Some(true) when requested");
                 Ok(())
             }

This ensures the server actually honors the request rather than just returning any value.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29b9877 and 53a95b7.

📒 Files selected for processing (1)
  • src/search.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
Repo: meilisearch/meilisearch-rust PR: 625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.

Applied to files:

  • src/search.rs
🧬 Code graph analysis (1)
src/search.rs (3)
src/client.rs (4)
  • None (1446-1446)
  • None (1525-1525)
  • index (424-426)
  • new (54-66)
src/indexes.rs (26)
  • client (186-188)
  • client (232-234)
  • client (320-322)
  • client (376-378)
  • client (428-430)
  • client (473-475)
  • client (522-525)
  • client (556-558)
  • client (634-636)
  • client (700-702)
  • client (970-972)
  • client (1038-1040)
  • client (1089-1091)
  • client (1133-1135)
  • client (1186-1188)
  • client (1245-1247)
  • index (2171-2171)
  • index (2188-2189)
  • index (2226-2226)
  • index (2298-2298)
  • index (2326-2326)
  • index (2352-2352)
  • index (2379-2379)
  • new (81-89)
  • new (1783-1790)
  • new (1994-2000)
src/documents.rs (8)
  • index (62-64)
  • index (161-161)
  • index (350-350)
  • index (487-487)
  • setup_test_index (423-451)
  • new (89-94)
  • new (209-218)
  • new (367-372)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: integration-tests
🔇 Additional comments (6)
src/search.rs (6)

118-120: LGTM! Field correctly implements exhaustive facet count in search results.

The field name, type, and documentation are appropriate. With the struct-level #[serde(rename_all = "camelCase")] attribute, this will correctly serialize/deserialize as exhaustiveFacetCount.


414-419: LGTM! Query parameter correctly configured for exhaustive facet counting.

The field is properly configured with serde attributes to skip serialization when unset, and the documentation clearly explains its purpose and default behavior.


466-466: LGTM! Proper initialization in constructor.

The field is correctly initialized to None, consistent with other optional query parameters.


735-742: LGTM! Builder method correctly implements the pattern.

The method follows the established builder pattern and is consistent with the existing FacetSearchQuery::with_exhaustive_facet_count method.


1113-1113: LGTM! Import required for the new test.

The ErrorCode import is needed for error handling in the test_search_with_exhaustive_facet_count test.


2028-2048: LGTM! Excellent serialization test.

This unit test provides valuable verification that the field serializes to the correct camelCase name exhaustiveFacetCount, which is critical for API compatibility with Meilisearch v1.14. The test would catch any naming regressions.

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

thank you

bors merge

meili-bors bot added a commit that referenced this pull request Nov 20, 2025
724: Add method to get documents by ID r=curquiza a=kumarUjjawal

# Pull Request

## Related issue
Fixes #662 

## What does this PR do?
- Added a method to get the documents by ID
- also added code samples

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Added capability to retrieve documents by their IDs for more targeted queries.

* **Documentation**
  * Added code sample demonstrating ID-based document retrieval.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

725: Update diesel-async requirement from 0.6.1 to 0.7.3 r=curquiza a=dependabot[bot]

Updates the requirements on [diesel-async](https://github.com/weiznich/diesel_async) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/weiznich/diesel_async/releases">diesel-async's releases</a>.</em></p>
<blockquote>
<h2>Diesel-Async 0.7.3</h2>
<ul>
<li>Another attempt to fix the docs.rs build by <a href="https://github.com/paolobarbolini"><code>`@​paolobarbolini</code></a></li>`
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/weiznich/diesel_async/compare/v0.7.2...v0.7.3">https://github.com/weiznich/diesel_async/compare/v0.7.2...v0.7.3</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/weiznich/diesel_async/blob/main/CHANGELOG.md">diesel-async's changelog</a>.</em></p>
<blockquote>
<h2>[0.7.3] - 2025-10-05</h2>
<ul>
<li>Another docs.rs build fix</li>
</ul>
<h2>[0.7.2] - 2025-10-02</h2>
<ul>
<li>Fix versions in the Readme</li>
</ul>
<h2>[0.7.1] - 2025-10-02</h2>
<ul>
<li>Fix the docs.rs build</li>
</ul>
<h2>[0.7.0] - 2025-10-02</h2>
<ul>
<li>Support for diesel 2.3</li>
<li>Added support for running migrations via <code>AsyncMigrationHarness</code></li>
<li>Improved ergonomics of using query pipelining with <code>AsyncPgConnection</code></li>
<li>Added the ability to cancel queries using <code>AsyncMysqlConnection::cancel_token</code></li>
</ul>
<h2>[0.6.1] - 2025-07-03</h2>
<ul>
<li>Fix features for some dependencies</li>
</ul>
<h2>[0.6.0] - 2025-07-02</h2>
<ul>
<li>Allow to control the statement cache size</li>
<li>Minimize dependencies features</li>
<li>Bump minimal supported mysql_async version to 0.36.0</li>
<li>Fixing a bug in how we tracked open transaction that could lead to dangling transactions is specific cases</li>
</ul>
<h2>[0.5.2] - 2024-11-26</h2>
<ul>
<li>Fixed an issue around transaction cancellation that could lead to connection pools containing connections with dangling transactions</li>
</ul>
<h2>[0.5.1] - 2024-11-01</h2>
<ul>
<li>Add crate feature <code>pool</code> for extending connection pool implements through external crate</li>
<li>Implement <code>Deref</code> and <code>DerefMut</code> for <code>AsyncConnectionWrapper</code> to allow using it in an async context as well</li>
</ul>
<h2>[0.5.0] - 2024-07-19</h2>
<ul>
<li>Added type <code>diesel_async::pooled_connection::mobc::PooledConnection</code></li>
<li>MySQL/MariaDB now use <code>CLIENT_FOUND_ROWS</code> capability to allow consistent behaviour with PostgreSQL regarding return value of UPDATe commands.</li>
<li>The minimal supported rust version is now 1.78.0</li>
<li>Add a <code>SyncConnectionWrapper</code> type that turns a sync connection into an async one. This enables SQLite support for diesel-async</li>
<li>Add support for <code>diesel::connection::Instrumentation</code> to support logging and other instrumentation for any of the provided connection impls.</li>
<li>Bump minimal supported mysql_async version to 0.34</li>
</ul>
<h2>[0.4.1] - 2023-09-01</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/weiznich/diesel_async/commit/e5e71da49416159f593f4896375e5e5c3a3b103c"><code>e5e71da</code></a> Prepare a 0.7.3 release to finally fix the docs.rs build</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/dacc14b0148a0a7dceb3337d0aeb2577bce67d4e"><code>dacc14b</code></a> Merge pull request <a href="https://github.com/weiznich/diesel_async/issues/265">#265</a> from paolobarbolini/no-docsrs-in-rustc</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/4ae157321ebf3bcd69264765bd43400449f6aaa1"><code>4ae1573</code></a> Fix docs.rs build by avoiding <code>--cfg docsrs</code> in rustc flags</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/46cd5fed6b7ac0a7f7b1b6e1a1283fece3813fe9"><code>46cd5fe</code></a> Fix versions in the readme</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/d5ac63e13307077babf976e02ef6bbab8353f079"><code>d5ac63e</code></a> Fix docs.rs build</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/df4c823d38d0c4e1e8d78bff5977986c8107068d"><code>df4c823</code></a> Explicitly specify what should be published and what not</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/4c449530625df0580ef9d19a055109a2385ae90a"><code>4c44953</code></a> Merge pull request <a href="https://github.com/weiznich/diesel_async/issues/264">#264</a> from weiznich/prepare/0.7.0</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/d0c4ea025d85616f95d368b951f92ff784ed721a"><code>d0c4ea0</code></a> Prepare a 0.7.0 release</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/356919091e47968ca2dcc534b533cf4cb62de958"><code>3569190</code></a> Merge pull request <a href="https://github.com/weiznich/diesel_async/issues/262">#262</a> from stormshield-kg/fix-hrtb-errors</li>
<li><a href="https://github.com/weiznich/diesel_async/commit/661de8c4442a123ccde74001b44fc6a154dbc4b2"><code>661de8c</code></a> Replace hand written future impls</li>
<li>Additional commits viewable in <a href="https://github.com/weiznich/diesel_async/compare/v0.6.1...v0.7.3">compare view</a></li>
</ul>
</details>
<br />


You can trigger a rebase of this PR by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

726: Add exhaustive facet search r=curquiza a=kumarUjjawal

# Pull Request

## Related issue
Fixes #664

## What does this PR do?
- 

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Results now include a flag indicating whether facet counts are exact or estimated, so callers can know when displayed facet totals are definitive.
  * Added an optional query setting and a builder-style method to request exhaustive (exact) facet counts when performing searches, giving users control over accuracy vs. performance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

728: Add support for compacting database indexes r=curquiza a=kumarUjjawal

# Pull Request

## Related issue
Fixes #727 

## What does this PR do?
- I noticed a typo in the `.code-samples.meilisearch.yaml` so fixed that as well.
- 
## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added ability to perform index compaction and monitor its completion as an async task.

* **Documentation**
  * Added compact index code sample.
  * Fixed typos in field properties guide examples (corrected "overview" in searchable and displayed attributes).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Kumar Ujjawal <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@curquiza curquiza added the enhancement New feature or request label Nov 20, 2025
@meili-bors
Copy link
Contributor

meili-bors bot commented Nov 20, 2025

This PR was included in a batch that successfully built, but then failed to merge into main. It will not be retried.

Additional information:

{"message":"Changes must be made through a pull request.","documentation_url":"https://docs.github.com/articles/about-protected-branches","status":"422"}

@curquiza
Copy link
Member

bors merge

@meili-bors
Copy link
Contributor

meili-bors bot commented Nov 21, 2025

Build succeeded:

@meili-bors meili-bors bot merged commit bcc931a into meilisearch:main Nov 21, 2025
8 of 9 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.

[v1.14] Add exhaustive facet search

2 participants