Skip to content

Add exhaustive facet count to facet search requests - #989

Open
m0g3r wants to merge 2 commits into
meilisearch:mainfrom
m0g3r:feat/843-exhaustive-facet-count
Open

Add exhaustive facet count to facet search requests#989
m0g3r wants to merge 2 commits into
meilisearch:mainfrom
m0g3r:feat/843-exhaustive-facet-count

Conversation

@m0g3r

@m0g3r m0g3r commented Aug 11, 2026

Copy link
Copy Markdown

Summary

  • add the optional exhaustiveFacetCount field to FacetSearchRequest
  • include the field in facet-search JSON only when callers set it
  • cover default omission, setter serialization, and builder access
  • cover explicit false, which must serialize rather than be omitted

Closes #843

Testing

  • ./gradlew test — 117 tests, 0 failures, including JaCoCo coverage verification
  • bash ./scripts/lint.sh — passed, spotless reports no changes
  • ./gradlew integrationTest — completed with NO-SOURCE; no integration tests ran through that task

Run on Temurin 17, matching sourceCompatibility and CI. Three SettingsHandlerTest cases need a
Meilisearch instance on localhost:7700; they pass with one running and fail with a connection
error without it.

Review follow-up

exhaustiveFacetCount is a boxed Boolean, so null means "omit" while false must still be
sent. The original tests only covered true, which would let a "falsy means omit" regression pass
unnoticed. serializesExhaustiveFacetCountWhenFalse closes that gap by asserting the key is
present and its value is false.

AI assistance

AI assistance was used materially throughout. Codex helped inspect the repository and draft the
initial implementation and tests; Claude Code added the explicit-false regression test and ran
the verification listed above. The full diff was reviewed before submission. I can't attribute
every line to one tool or the other, so both are named rather than guessed at.

Summary by CodeRabbit

  • New Features
    • Added support for requesting exhaustive facet counts during facet searches.
    • The option can be configured through setters or the request builder and is included in requests when enabled.

@coderabbitai

coderabbitai Bot commented Aug 11, 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 Plus

Run ID: 5d4c78f7-b88b-4663-8b8b-10bcfb797ddf

📥 Commits

Reviewing files that changed from the base of the PR and between e9fb212 and cbb6676.

📒 Files selected for processing (1)
  • src/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java

📝 Walkthrough

Walkthrough

FacetSearchRequest now supports the exhaustiveFacetCount Boolean option. The option is serialized when set. Tests cover default omission, configuration, serialization, and getter retrieval.

Changes

Facet Search Request

Layer / File(s) Summary
Add and validate exhaustive facet count
src/main/java/com/meilisearch/sdk/FacetSearchRequest.java, src/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java
FacetSearchRequest adds the exhaustiveFacetCount property and includes it in JSON when present. Tests verify default omission, setter and builder configuration, serialization, and getter retrieval.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit checks the count,
With facets lined in rows.
The builder sets the value,
And JSON neatly shows.
Tests confirm each case.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds optional exhaustiveFacetCount serialization to FacetSearchRequest and tests the required request behavior for issue #843.
Out of Scope Changes check ✅ Passed All code and test changes directly support exhaustiveFacetCount in facet search requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of exhaustive facet count support to facet search requests.
✨ 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.

🧹 Nitpick comments (1)
src/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java (1)

18-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for explicit false.

exhaustiveFacetCount uses Boolean, so null means omitted and false must remain serialized. The current test covers only true. Add a test that asserts the key is present and its value is false.

Proposed test
+    `@Test`
+    void serializesExplicitFalseExhaustiveFacetCount() {
+        FacetSearchRequest request =
+                new FacetSearchRequest("genres").setExhaustiveFacetCount(false);
+
+        JSONObject json = new JSONObject(request.toString());
+
+        assertThat(json.has("exhaustiveFacetCount"), is(true));
+        assertThat(json.getBoolean("exhaustiveFacetCount"), is(false));
+    }
🤖 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/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java` around lines
18 - 25, Add a separate test alongside serializesExhaustiveFacetCount that
creates a FacetSearchRequest with setExhaustiveFacetCount(false), parses its
serialized JSON, and asserts exhaustiveFacetCount is present with a false value.
🤖 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.

Nitpick comments:
In `@src/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java`:
- Around line 18-25: Add a separate test alongside
serializesExhaustiveFacetCount that creates a FacetSearchRequest with
setExhaustiveFacetCount(false), parses its serialized JSON, and asserts
exhaustiveFacetCount is present with a false value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ee79792-2fa5-43e4-96b5-544eedd19262

📥 Commits

Reviewing files that changed from the base of the PR and between 740d3f6 and e9fb212.

📒 Files selected for processing (2)
  • src/main/java/com/meilisearch/sdk/FacetSearchRequest.java
  • src/test/java/com/meilisearch/sdk/FacetSearchRequestTest.java

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.14] Add exhaustive facet search

1 participant