Add stats size format options
Pull Request
Related issue
Fixes #966
What does this PR do?
- Adds
StatsQuerysupport for theshowInternalDatabaseSizesandsizeFormatquery parameters. - Adds parameterized stats methods for global stats and index stats.
- Adds response models that support raw numeric sizes and human-readable size strings.
- Represents
internalDatabaseSizesas a flexible map. - Updates tests for the new stats query parameters and response handling.
- Updates
.code-samples.meilisearch.yamlforget_index_stats_1andget_indexes_stats_1.
PR checklist
Please check if your PR fulfills the following requirements:
- [x] Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
- Used ChatGPT/Codex to inspect the SDK structure, implement the stats query/model changes, add focused tests, and prepare this PR description.
- [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?
Tests
.\gradlew.bat testClasses.\gradlew.bat test --tests com.meilisearch.sdk.StatsTest --init-script <disable-jacoco> -x jacocoTestReport -x jacocoTestCoverageVerification --rerun-tasks
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit
- New Features
- Stats requests can now include options for internal database sizes and human-readable size formatting.
- Added overloads to retrieve enhanced stats at both the app-wide and index levels.
- Bug Fixes
- Updated Java stats examples to use the query-based approach for size formatting and internal size visibility.
- Tests
- Added coverage for stats query serialization and parsing of both human-formatted and raw numeric size responses for global and index stats.
📝 Walkthrough
Walkthrough
This PR adds StatsQuery support for stats endpoints, introduces size-format stats response models, wires new getStats overloads through the SDK, and updates tests and code samples for the new query parameters and response shapes.
Changes
Stats query parameter support
| Layer / File(s) | Summary |
|---|---|
StatsQuery and response models src/main/java/com/meilisearch/sdk/model/StatsQuery.java, .../StatsWithSizeFormat.java, .../IndexStatsWithSizeFormat.java |
Adds StatsQuery serialization and new stats response models that carry size values as Object and include nested index stats. |
Stats retrieval wiring src/main/java/com/meilisearch/sdk/InstanceHandler.java, src/main/java/com/meilisearch/sdk/Client.java, src/main/java/com/meilisearch/sdk/Index.java |
Updates stats fetch paths to accept StatsQuery, build query-parameterized URLs, and return the new size-format response types. |
Tests and samples src/test/java/com/meilisearch/sdk/StatsTest.java, .code-samples.meilisearch.yaml |
Adds coverage for query serialization, human-formatted and raw size responses, and updates stats code samples to pass StatsQuery. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Possibly related issues
- meilisearch/meilisearch-rust#789: Same stats API update with query parameters, size-formatted models, tests, and docs in another SDK.
- meilisearch/meilisearch-dart#488: Same
showInternalDatabaseSizesandsizeFormatstats change across equivalent SDK surfaces. - meilisearch/meilisearch-ruby#697: Same stats endpoint query-parameter support for index and global stats.
- meilisearch/meilisearch-swift#521: Same stats API enhancement for human sizes and internal database sizes.
- meilisearch/meilisearch-dotnet#735: Same stats methods, models, tests, and docs update.
- meilisearch/meilisearch-python#1234: Same stats API and sample updates for the Python SDK.
Poem
Hop hop, I fetched stats today, With human sizes on display. Query params in every hop, Little ears up, stats don’t stop. 🐇
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title is concise and accurately summarizes the main change: adding size format options to stats APIs. |
| Linked Issues check | ✅ Passed | The PR adds the new stats query methods, response models, tests, and code-sample updates required by #966. |
| Out of Scope Changes check | ✅ Passed | The changes stay focused on stats API support, related models, tests, and documentation samples. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ 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.
Comment @coderabbitai help to get the list of available commands.
Thanks for the review. Since the duplicated setup keeps the raw-size and human-size cases explicit and readable, I’ll leave this as-is for now unless maintainers prefer a helper-based refactor.