Add document database stats

This commit is contained in:
ManyTheFish 2025-02-10 14:10:13 +01:00 committed by Kerollmops
parent 91a8a97045
commit 9a6c1730aa
No known key found for this signature in database
GPG key ID: F250A4C4E3AE5F5F
9 changed files with 145 additions and 6 deletions

View file

@ -494,6 +494,12 @@ pub async fn delete_index(
pub struct IndexStats {
/// Number of documents in the index
pub number_of_documents: u64,
/// Size of the documents database, in bytes.
pub raw_document_db_size: u64,
/// Maximum size of a document in the documents database.
pub max_document_size: u64,
/// Average size of a document in the documents database.
pub avg_document_size: u64,
/// Whether or not the index is currently ingesting document
pub is_indexing: bool,
/// Number of embeddings in the index
@ -510,7 +516,10 @@ pub struct IndexStats {
impl From<index_scheduler::IndexStats> for IndexStats {
fn from(stats: index_scheduler::IndexStats) -> Self {
IndexStats {
number_of_documents: stats.inner_stats.number_of_documents,
number_of_documents: stats.inner_stats.documents_database_stats.number_of_entries(),
raw_document_db_size: stats.inner_stats.documents_database_stats.total_value_size(),
max_document_size: stats.inner_stats.documents_database_stats.max_value_size(),
avg_document_size: stats.inner_stats.documents_database_stats.average_value_size(),
is_indexing: stats.is_indexing,
number_of_embeddings: stats.inner_stats.number_of_embeddings,
number_of_embedded_documents: stats.inner_stats.number_of_embedded_documents,