Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

chore: add extra batch size logging to the meilisearch plugin

Mohamed Bassem885355bb0e9b
diff --git a/.husky/pre-commit b/.husky/pre-commit
old mode 100644
new mode 100755
diff --git a/packages/plugins/search-meilisearch/src/index.ts b/packages/plugins/search-meilisearch/src/index.ts
index 5ebbd2ec..cf61df7a 100644
--- a/packages/plugins/search-meilisearch/src/index.ts
+++ b/packages/plugins/search-meilisearch/src/index.ts
@@ -105,6 +105,21 @@ class BatchingDocumentQueue {
batch.push(this.pendingOperations.shift()!);
}
+ let reason: string;
+ if (batch.length >= this.batchSize) {
+ reason = "batch size limit reached";
+ } else if (
+ this.pendingOperations.length > 0 &&
+ this.pendingOperations[0].type !== currentType
+ ) {
+ reason = "operation type changed";
+ } else {
+ reason = "no more pending operations";
+ }
+ console.log(
+ `[meilisearch] Flushing ${currentType} batch: size=${batch.length}, remaining=${this.pendingOperations.length}, reason="${reason}"`,
+ );
+
if (currentType === "add") {
await this.flushAddBatch(
batch as Extract<PendingOperation, { type: "add" }>[],