Parcourir la source

fix(elasticsearch): ensure temporary index is deleted before reindexing

Ryu Sato il y a 1 semaine
Parent
commit
54a8f3bb0d

+ 6 - 0
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -347,6 +347,12 @@ class ElasticsearchDelegator
 
     try {
       // reindex to tmp index
+      const isExistsTmpIndex = await client.indices.exists({
+        index: tmpIndexName,
+      });
+      if (isExistsTmpIndex) {
+        await client.indices.delete({ index: tmpIndexName });
+      }
       await this.createIndex(tmpIndexName);
       await client.reindex(indexName, tmpIndexName);