Procházet zdrojové kódy

fix: PUT /_api/v3/search/indice

Shun Miyazawa před 2 roky
rodič
revize
81481c0b95

+ 13 - 5
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -281,16 +281,24 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
 
 
     const tmpIndexName = `${indexName}-tmp`;
     const tmpIndexName = `${indexName}-tmp`;
 
 
-    try {
-      // reindex to tmp index
-      await this.createIndex(tmpIndexName);
-      await client.reindex({
+    const reindexRequest = this.isElasticsearchV7
+      ? {
         waitForCompletion: false,
         waitForCompletion: false,
         body: {
         body: {
           source: { index: indexName },
           source: { index: indexName },
           dest: { index: tmpIndexName },
           dest: { index: tmpIndexName },
         },
         },
-      });
+      }
+      : {
+        wait_for_completion: false,
+        source: { index: indexName },
+        dest: { index: tmpIndexName },
+      };
+
+    try {
+      // reindex to tmp index
+      await this.createIndex(tmpIndexName);
+      await client.reindex(reindexRequest);
 
 
       // update alias
       // update alias
       await client.indices.updateAliases({
       await client.indices.updateAliases({