mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-26 00:01:00 +00:00
Fix stats showing wrong document count after clear all
Update database stats after clearing documents to ensure /stats endpoint returns correct numberOfDocuments: 0 instead of stale count.
This commit is contained in:
@ -2,7 +2,7 @@ use heed::RwTxn;
|
||||
use roaring::RoaringBitmap;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::{FieldDistribution, Index, Result};
|
||||
use crate::{database_stats::DatabaseStats, FieldDistribution, Index, Result};
|
||||
|
||||
pub struct ClearDocuments<'t, 'i> {
|
||||
wtxn: &'t mut RwTxn<'i>,
|
||||
@ -92,6 +92,10 @@ impl<'t, 'i> ClearDocuments<'t, 'i> {
|
||||
|
||||
documents.clear(self.wtxn)?;
|
||||
|
||||
// Update the stats of the documents database after clearing all documents.
|
||||
let stats = DatabaseStats::new(self.index.documents.remap_data_type(), self.wtxn)?;
|
||||
self.index.put_documents_stats(self.wtxn, stats)?;
|
||||
|
||||
Ok(number_of_documents)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user