Просмотр исходного кода

fix: PUT /_api/v3/search/indice

Shun Miyazawa 2 лет назад
Родитель
Сommit
81481c0b95
1 измененных файлов с 13 добавлено и 5 удалено
  1. 13 5
      apps/app/src/server/service/search-delegator/elasticsearch.ts

+ 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`;
 
-    try {
-      // reindex to tmp index
-      await this.createIndex(tmpIndexName);
-      await client.reindex({
+    const reindexRequest = this.isElasticsearchV7
+      ? {
         waitForCompletion: false,
         body: {
           source: { index: indexName },
           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
       await client.indices.updateAliases({