Skip to content

Add sampledCount faceting examples and tests - #1297

Open
WilliamK112 wants to merge 1 commit into
meilisearch:mainfrom
WilliamK112:add-sampled-count-faceting-1296
Open

WilliamK112 wants to merge 1 commit into
meilisearch:mainfrom
WilliamK112:add-sampled-count-faceting-1296

Conversation

@WilliamK112

@WilliamK112 WilliamK112 commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

  • cover sampledCount as the fallback facet sort order and as a per-attribute sort order
  • verify resetting faceting after configuring sampledCount restores the defaults
  • update the update_faceting_settings_1 code sample to use sampledCount

Closes #1296

Testing

  • uv run pytest -q tests/settings/test_setting_faceting.py (9 passed against Meilisearch v1.56.0)
  • uv run ruff check .
  • uv run ruff format --check .
  • uv run mypy meilisearch
  • Full suite: 387 passed, 5 skipped; two existing inline-rule tests require Meilisearch Enterprise Edition and return requires_enterprise_edition against the v1.56.0 OSS image used locally.

AI disclosure

Codex assisted with locating the relevant tests and code sample, drafting the focused changes, and running verification. I reviewed and validated all changes.

Summary by CodeRabbit

  • Documentation
    • Updated faceting examples to show alphabetical ordering for unspecified facet values and sampled-count ordering for genre values.
  • Tests
    • Updated faceting checks to cover wildcard and genre sorting, and expanded reset coverage for facet limits and sorting settings.

Signed-off-by: Ching-Wei Kang <ckang53@wisc.edu>
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f6c8a677-c188-4cff-865f-aeb5ce8d23a3
Commits

Reviewing files that changed from the base of the PR and between b6d8020 and 245db4c.

Files selected for processing: 2
  • .code-samples.meilisearch.yaml
  • tests/settings/test_setting_faceting.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The faceting example now uses alpha sorting for wildcard facets and sampledCount sorting for genres. The settings tests cover sampledCount for wildcard and attribute-specific keys, including reset setup.

Changes: Faceting settings

Layer / File(s) Summary
Sampled-count settings and validation
.code-samples.meilisearch.yaml, tests/settings/test_setting_faceting.py
The example and tests cover sampledCount sorting for wildcard and genres facets. The reset test setup configures both keys with sampledCount.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Suggested reviewers: sanders41

Merge Risk: Minimal · up to 245db

The sampledCount support and documentation changes are ready to merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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 sampledCount faceting examples and tests" matches the main change. The PR adds sampledCount support coverage in faceting tests, a reset test update, and an update to the update_faceting…
Linked Issues check Passed Issue #1296 requires sampledCount support, readback, reset coverage, and a code sample. The existing Faceting.sort_facet_values_by: dict[str, str] model accepts the new value without a separate en…
Out of Scope Changes check Passed The changes are limited to the issue's faceting tests and the requested update_faceting_settings_1 code sample. The test changes directly verify the new fallback, per-attribute, and reset behavior.
Full details: Title check

Explanation

The title "Add sampledCount faceting examples and tests" matches the main change. The PR adds sampledCount support coverage in faceting tests, a reset test update, and an update to the update_faceting_settings_1 code sample to use sampledCount. The title is specific and names the primary change, which is the sampledCount faceting support in tests and examples. It is a short single sentence and does not use vague terms.

Full details: Linked Issues check

Explanation

Issue #1296 requires sampledCount support, readback, reset coverage, and a code sample. The existing Faceting.sort_facet_values_by: dict[str, str] model accepts the new value without a separate enum. The tests update and read back sampledCount for * and genres, and reset both values to the default settings. The code sample uses sampledCount for genres and alpha for the fallback.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

[Meilisearch v1.56] Add support for sampledCount in faceting sortFacetValuesBy

1 participant