diff --git a/src/brainyData.ts b/src/brainyData.ts index 29c7fff4..be83fa59 100644 --- a/src/brainyData.ts +++ b/src/brainyData.ts @@ -4292,7 +4292,12 @@ export class BrainyData implements BrainyDataInterface { ) // Explicitly clear the index for the storage test - this.index.clear() + await this.index.clear() + + // Ensure statistics are properly flushed to avoid inconsistencies + if (this.storage) { + await this.storage.flushStatisticsToStorage() + } } else { // Re-add all nouns to the index for normal operation for (const noun of data.nouns) {