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

remove USE_ELASTICSEARCH_V6 and add ELASTICSEARCH_VERSION

Yuki Takei 4 лет назад
Родитель
Сommit
09d276cf15

+ 0 - 1
packages/app/.env.development

@@ -12,7 +12,6 @@ MATHJAX=1
 MONGO_URI="mongodb://mongo:27017/growi"
 MONGO_URI="mongodb://mongo:27017/growi"
 # REDIS_URI="http://redis:6379"
 # REDIS_URI="http://redis:6379"
 # NCHAN_URI="http://nchan"
 # NCHAN_URI="http://nchan"
-USE_ELASTICSEARCH_V6=false
 ELASTICSEARCH_URI="http://elasticsearch:9200/growi"
 ELASTICSEARCH_URI="http://elasticsearch:9200/growi"
 ELASTICSEARCH_REQUEST_TIMEOUT=15000
 ELASTICSEARCH_REQUEST_TIMEOUT=15000
 ELASTICSEARCH_REJECT_UNAUTHORIZED=true
 ELASTICSEARCH_REJECT_UNAUTHORIZED=true

+ 6 - 6
packages/app/src/server/service/config-loader.ts

@@ -295,6 +295,12 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    ValueType.STRING,
     type:    ValueType.STRING,
     default: '/growi-internal/',
     default: '/growi-internal/',
   },
   },
+  ELASTICSEARCH_VERSION: {
+    ns:      'crowi',
+    key:     'app:elasticsearchVersion',
+    type:    ValueType.NUMBER,
+    default: 7,
+  },
   ELASTICSEARCH_URI: {
   ELASTICSEARCH_URI: {
     ns:      'crowi',
     ns:      'crowi',
     key:     'app:elasticsearchUri',
     key:     'app:elasticsearchUri',
@@ -325,12 +331,6 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    ValueType.BOOLEAN,
     type:    ValueType.BOOLEAN,
     default: false,
     default: false,
   },
   },
-  USE_ELASTICSEARCH_V6: {
-    ns:      'crowi',
-    key:     'app:useElasticsearchV6',
-    type:    ValueType.BOOLEAN,
-    default: true,
-  },
   MONGO_GRIDFS_TOTAL_LIMIT: {
   MONGO_GRIDFS_TOTAL_LIMIT: {
     ns:      'crowi',
     ns:      'crowi',
     key:     'gridfs:totalLimit',
     key:     'gridfs:totalLimit',

+ 7 - 1
packages/app/src/server/service/search-delegator/elasticsearch.ts

@@ -67,7 +67,13 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
     this.configManager = configManager;
     this.configManager = configManager;
     this.socketIoService = socketIoService;
     this.socketIoService = socketIoService;
 
 
-    this.isElasticsearchV6 = this.configManager.getConfig('crowi', 'app:useElasticsearchV6');
+    const elasticsearchVersion: number = this.configManager.getConfig('crowi', 'app:elasticsearchVersion');
+
+    if (elasticsearchVersion !== 6 && elasticsearchVersion !== 7) {
+      throw new Error('Unsupported Elasticsearch version. Please specify a valid number to \'ELASTICSEARCH_VERSION\'');
+    }
+
+    this.isElasticsearchV6 = elasticsearchVersion === 6;
 
 
     this.elasticsearch = this.isElasticsearchV6 ? elasticsearch6 : elasticsearch7;
     this.elasticsearch = this.isElasticsearchV6 ? elasticsearch6 : elasticsearch7;
     this.isElasticsearchReindexOnBoot = this.configManager.getConfig('crowi', 'app:elasticsearchReindexOnBoot');
     this.isElasticsearchReindexOnBoot = this.configManager.getConfig('crowi', 'app:elasticsearchReindexOnBoot');