From 0d632eabbfd512c813e65212c3f5765bbc3fc8c7 Mon Sep 17 00:00:00 2001 From: Priyash <38959321+priyashpatil@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:22:23 +0530 Subject: [PATCH] fix: delete old docs index on force re-index (#1778) --- core/indexing/docs/DocsService.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 9cd8feb5f..b2eb7b350 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -296,6 +296,12 @@ export class DocsService { status: "indexing", }; + // Clear old index if re-indexing. + if (reIndex) { + console.log("Deleting old embeddings"); + await this.delete(startUrl.toString()); + } + await this.add(siteIndexingConfig.title, startUrl, chunks, embeddings); this.docsIndexingQueue.delete(startUrl.toString());