Kaynağa Gözat

Added support of BONSAI_URL

Sotaro KARASAWA 10 yıl önce
ebeveyn
işleme
4ee608f54e
2 değiştirilmiş dosya ile 11 ekleme ve 4 silme
  1. 1 0
      lib/crowi/index.js
  2. 10 4
      lib/util/search.js

+ 1 - 0
lib/crowi/index.js

@@ -201,6 +201,7 @@ Crowi.prototype.getMailer = function() {
 Crowi.prototype.setupSearcher = function() {
   var self = this;
   var searcherUri = this.env.ELASTICSEARCH_URI
+    || this.env.BONSAI_URL
     || null
     ;
 

+ 10 - 4
lib/util/search.js

@@ -45,14 +45,20 @@ SearchClient.prototype.shouldIndexed = function(page) {
   return true;
 };
 
+
+// BONSAI_URL is following format:
+// => https://{ID}:{PASSWORD}@{HOST}
 SearchClient.prototype.parseUri = function(uri) {
-  if (!(m = uri.match(/^elasticsearch:\/\/([^:]+):([^\/]+)\/(.+)$/))) {
-    throw new Error('Invalid ELASTICSEARCH_URI format. Should be elasticsearch://host:port/index_name');
+  var index_name = 'crowi';
+  var host = uri;
+  if (m = uri.match(/^(https?:\/\/[^\/]+)\/(.+)$/)) {
+    host = m[1];
+    index_name = m[2];
   }
 
   return {
-    host: m[1] + ':' + m[2],
-    index_name: m[3],
+    host,
+    index_name,
   };
 };