Skip to content

feat(stats): add indexSize and usedIndexSize to index stats response (#988) - #990

Open
krishna3006b wants to merge 2 commits into
meilisearch:mainfrom
krishna3006b:feat/add-index-size-stats
Open

feat(stats): add indexSize and usedIndexSize to index stats response (#988)#990
krishna3006b wants to merge 2 commits into
meilisearch:mainfrom
krishna3006b:feat/add-index-size-stats

Conversation

@krishna3006b

@krishna3006b krishna3006b commented Aug 11, 2026

Copy link
Copy Markdown

Description

Resolves #988.

Updated \IndexStats\ model in \meilisearch-java\ SDK to include:

  • \indexSize: DB size of the index in bytes
  • \usedIndexSize: size of the used pages in the index DB

Added @JsonProperty\ annotations and unit tests for both \GsonJsonHandlerTest\ and \JacksonJsonHandlerTest.

Related Issue

Fixes #988

Tests

  • Unit tests updated & passing (./gradlew test)
  • Tested deserialization for both Gson & Jackson handlers

Summary by CodeRabbit

  • New Features

    • Index statistics now include total index size and used index size.
    • Existing index statistics constructors remain compatible, with new storage values defaulting to zero.
  • Bug Fixes

    • Improved JSON serialization and deserialization of index statistics, including consistent isIndexing status handling.
  • Tests

    • Added coverage for document, embedding, status, distribution, and storage statistics across supported JSON handlers.

Copilot AI lite review requested due to automatic review settings August 11, 2026 06:54
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

IndexStats now includes indexSize and usedIndexSize, supports JSON property mapping and generated setters, preserves the existing constructor, and adds Gson and Jackson serialization and deserialization tests.

Changes

Index statistics update

Layer / File(s) Summary
IndexStats model and constructors
src/main/java/com/meilisearch/sdk/model/IndexStats.java
IndexStats adds JSON annotations, generated setters, indexSize, and usedIndexSize. The existing constructor delegates to a new constructor with size parameters.
JSON serialization and deserialization coverage
src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java, src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java
Gson and Jackson tests verify both index size fields. Jackson tests also verify serialization of the isIndexing property.

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

Possibly related issues

  • meilisearch/meilisearch-go#809 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-dotnet#757 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-python#1274 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-ruby#711 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-rust#804 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-swift#531 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-php#943 — Adds the same index statistics fields and related tests.
  • meilisearch/meilisearch-js#2220 — Adds the same index statistics fields and related tests.

Suggested reviewers: strift

Poem

I’m a rabbit with two stats to share,
indexSize and usedIndexSize are there.
Gson checks, Jackson too,
isIndexing stays true and true.
Clean data hops through the lair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly identifies the addition of both index size fields to index statistics.
Linked Issues check ✅ Passed The changes add both required fields to IndexStats and update Gson and Jackson tests for serialization and deserialization [#988].
Out of Scope Changes check ✅ Passed The constructor, setter, and JsonProperty updates support model binding and serialization for the requested index statistics fields.
✨ 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.

Actionable comments posted: 1

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

Inline comments:
In `@src/main/java/com/meilisearch/sdk/model/IndexStats.java`:
- Around line 38-42: Update IndexStats to use the API’s actual size
fields—databaseSize, usedDatabaseSize, rawDocumentDbSize, and
avgDocumentSize—instead of indexSize and usedIndexSize, and support both numeric
and human-formatted string values for each. Update both stats request paths to
request/map these fields correctly, and add Gson and Jackson
serialization/deserialization coverage for numeric and formatted responses.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 52e65cbb-9e8e-46c8-9dc6-4901883699ad

📥 Commits

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

📒 Files selected for processing (3)
  • src/main/java/com/meilisearch/sdk/model/IndexStats.java
  • src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java
  • src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java

Comment thread src/main/java/com/meilisearch/sdk/model/IndexStats.java Outdated

Copilot AI 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.

Pull request overview

Updates the Java SDK’s per-index stats model to support Meilisearch v1.53.0’s new indexSize and usedIndexSize fields, and extends JSON handler tests to validate deserialization for both Jackson and Gson.

Changes:

  • Extend IndexStats with indexSize and usedIndexSize.
  • Add Jackson @JsonProperty mappings to IndexStats fields.
  • Add unit tests to validate decoding of the new fields in both Jackson and Gson handlers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/com/meilisearch/sdk/model/IndexStats.java Adds the new stats fields and JSON mapping annotations.
src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java Adds a decoding test covering indexSize and usedIndexSize.
src/test/java/com/meilisearch/sdk/json/GsonJsonHandlerTest.java Adds a decoding test covering indexSize and usedIndexSize.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/java/com/meilisearch/sdk/model/IndexStats.java Outdated

@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/json/JacksonJsonHandlerTest.java (1)

196-208: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert both new size fields in the Jackson serialization test.

The test currently checks only isIndexing. It passes if Jackson omits indexSize or usedIndexSize. Add assertions for both serialized values.

Proposed test update
         assertThat(
                 json,
                 org.hamcrest.Matchers.not(org.hamcrest.Matchers.containsString("\"indexing\"")));
+        assertThat(json, org.hamcrest.Matchers.containsString("\"indexSize\":2048"));
+        assertThat(json, org.hamcrest.Matchers.containsString("\"usedIndexSize\":1500"));
🤖 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/json/JacksonJsonHandlerTest.java` around
lines 196 - 208, Update the serializeIndexStats test for IndexStats to assert
that the encoded JSON contains both new size fields, indexSize with value 2048
and usedIndexSize with value 1500, while preserving the existing isIndexing
assertion.
🤖 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/json/JacksonJsonHandlerTest.java`:
- Around line 196-208: Update the serializeIndexStats test for IndexStats to
assert that the encoded JSON contains both new size fields, indexSize with value
2048 and usedIndexSize with value 1500, while preserving the existing isIndexing
assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 45951c97-eb7c-4831-9707-d87c29e17f05

📥 Commits

Reviewing files that changed from the base of the PR and between 6ace6fc and 304a4b7.

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

@krishna3006b

Copy link
Copy Markdown
Author

@Strift Please review this

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.53.0] Add indexSize and usedIndexSize to index stats

2 participants