Explorar el Código

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

Ryu Sato hace 1 semana
padre
commit
54a8f3bb0d
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      apps/app/src/server/service/search-delegator/elasticsearch.ts

+ 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);