Skip to content

Add documents and embbedings database metrics to stats response #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1795,9 +1795,20 @@ impl<'a, Http: HttpClient> AsRef<IndexUpdater<'a, Http>> for IndexUpdater<'a, Ht
#[derive(Debug, Clone, Deserialize)]
Copy link
Contributor

@CommanderStorm CommanderStorm Jun 30, 2025

Choose a reason for hiding this comment

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

thinking about it, this should also be non_exhaustive.
There are bound to be more stats in the future

Suggested change
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]

#[serde(rename_all = "camelCase")]
pub struct IndexStats {
Copy link
Contributor

@CommanderStorm CommanderStorm Jun 30, 2025

Choose a reason for hiding this comment

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

Lets also add more doc-comments here

Suggested change
pub struct IndexStats {
/// Gives extended information and metrics about indexes and the Meilisearch database
pub struct IndexStats {

/// Total number of documents in an index
pub number_of_documents: usize,
/// If `true`, the index is still processing documents and attempts to search will result in undefined behavior
pub is_indexing: bool,
/// Shows every field in the index along with the total number of documents containing that field in said index
pub field_distribution: HashMap<String, usize>,
/// Storage space claimed by all documents in the index in bytes
pub raw_document_db_size: usize,
/// Total size of the documents stored in an index divided by the number of documents in that same index
pub avg_document_size: usize,
/// Total number of documents with at least one embedding
pub number_of_embedded_documents: usize,
/// Total number of embeddings in an index
pub number_of_embeddings: usize,
}

/// An [`IndexesQuery`] containing filter and pagination parameters when searching for [Indexes](Index).
Expand Down
Loading