manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1798195 - in /manifoldcf/trunk: ./ connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsear...
Date Fri, 09 Jun 2017 12:24:51 GMT
Author: kwright
Date: Fri Jun  9 12:24:51 2017
New Revision: 1798195

URL: http://svn.apache.org/viewvc?rev=1798195&view=rev
Log:
Fix for CONNECTORS-1431

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_en_US.properties
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_es_ES.properties
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_ja_JP.properties
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_zh_CN.properties
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_Parameters.html
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration.html

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Fri Jun  9 12:24:51 2017
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 2.8-dev =====================
 
+CONNECTORS-1431: Support different versions of ES (including 5.x and
+up).
+(Karl Wright, Hans Van Goethem)
+
 CONNECTORS-1428: Add support for configuring Tika extractor.
 (Julien Massiera, Karl Wright)
 

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
Fri Jun  9 12:24:51 2017
@@ -35,7 +35,7 @@ public class ElasticSearchAction extends
 
   public enum CommandEnum
   {
-    _optimize, _refresh, _stats;
+    _optimize, _refresh, _stats, _forcemerge;
   }
 
   public ElasticSearchAction(HttpClient client, ElasticSearchConfig config)

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
Fri Jun  9 12:24:51 2017
@@ -35,6 +35,7 @@ public class ElasticSearchConfig extends
   /** Parameters used for the configuration */
   final private static ParameterEnum[] CONFIGURATIONLIST =
   {
+    ParameterEnum.SERVERVERSION,
     ParameterEnum.SERVERLOCATION,
     ParameterEnum.INDEXNAME,
     ParameterEnum.INDEXTYPE,
@@ -95,6 +96,37 @@ public class ElasticSearchConfig extends
     }
   }
 
+  final public boolean isServerAfter5()
+  {
+    return getMajorVersion() >= 5;
+  }
+      
+  final public int getMajorVersion() {
+    final String version = getServerVersion();
+    if (version == null || version.length() == 0) {
+      return 0;
+    }
+    final int index = version.indexOf(".");
+    final String upperVersion;
+    if (index == -1) {
+      upperVersion = version;
+    } else {
+      upperVersion = version.substring(0, index);
+    }
+    int majorVersion;
+    try {
+      majorVersion = Integer.parseInt(upperVersion);
+    } catch (Exception e) {
+      majorVersion = 0;
+    }
+    return majorVersion;
+  }
+  
+  final public String getServerVersion()
+  {
+    return get(ParameterEnum.SERVERVERSION);
+  }
+  
   final public String getServerLocation()
   {
     return get(ParameterEnum.SERVERLOCATION);

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
Fri Jun  9 12:24:51 2017
@@ -427,12 +427,13 @@ public class ElasticSearchConnector exte
   public void noteJobComplete(IOutputNotifyActivity activities)
       throws ManifoldCFException, ServiceInterruption
   {
+    ElasticSearchConfig config = getConfigParameters(null);
     HttpClient client = getSession();
     long startTime = System.currentTimeMillis();
-    ElasticSearchAction oo = new ElasticSearchAction(client, getConfigParameters(null));
+    ElasticSearchAction oo = new ElasticSearchAction(client, config);
     try
     {
-      oo.execute(CommandEnum._optimize, false);
+      oo.execute(config.isServerAfter5()?CommandEnum._forcemerge:CommandEnum._optimize, false);
     }
     finally
     {

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
Fri Jun  9 12:24:51 2017
@@ -33,6 +33,8 @@ public class ElasticSearchParam extends
   /** Parameters constants */
   public enum ParameterEnum
   {
+    SERVERVERSION(""),
+    
     SERVERLOCATION("http://localhost:9200/"),
 
     INDEXNAME("index"),

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_en_US.properties?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_en_US.properties
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_en_US.properties
Fri Jun  9 12:24:51 2017
@@ -15,7 +15,8 @@
 
 ElasticSearchConnector.Parameters=Parameters
 
-ElasticSearchConnector.ServerLocation=Server Location
+ElasticSearchConnector.ServerVersion=Server version:
+ElasticSearchConnector.ServerLocation=Server location
 ElasticSearchConnector.URLColon=(URL):
 ElasticSearchConnector.IndexNameColon=Index name:
 ElasticSearchConnector.IndexTypeColon=Index type:

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_es_ES.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_es_ES.properties?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_es_ES.properties
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_es_ES.properties
Fri Jun  9 12:24:51 2017
@@ -15,6 +15,7 @@
 
 ElasticSearchConnector.Parameters=Parámetros
 
+ElasticSearchConnector.ServerVersion=Server version:
 ElasticSearchConnector.ServerLocation=Ubicación del servidor
 ElasticSearchConnector.URLColon=(URL):
 ElasticSearchConnector.IndexNameColon=El nombre de índice:

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_ja_JP.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_ja_JP.properties?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_ja_JP.properties
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_ja_JP.properties
Fri Jun  9 12:24:51 2017
@@ -15,6 +15,7 @@
 
 ElasticSearchConnector.Parameters=引数
 
+ElasticSearchConnector.ServerVersion=Server version:
 ElasticSearchConnector.ServerLocation=サーバ
 ElasticSearchConnector.URLColon=(URL):
 ElasticSearchConnector.IndexNameColon=インデックス名:

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_zh_CN.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_zh_CN.properties?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_zh_CN.properties
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/native2ascii/org/apache/manifoldcf/agents/output/elasticsearch/common_zh_CN.properties
Fri Jun  9 12:24:51 2017
@@ -15,6 +15,7 @@
 
 ElasticSearchConnector.Parameters=参数
 
+ElasticSearchConnector.ServerVersion=Server version:
 ElasticSearchConnector.ServerLocation=服务器
 ElasticSearchConnector.URLColon=(URL):
 ElasticSearchConnector.IndexNameColon=索引名: 

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_Parameters.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_Parameters.html?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_Parameters.html
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_Parameters.html
Fri Jun  9 12:24:51 2017
@@ -20,6 +20,14 @@
 <table class="displaytable">
   <tr>
     <td class="description">
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('ElasticSearchConnector.ServerVersion'))</nobr>
+    </td>
+    <td class="value"><input name="serverversion" type="text"
+      value="$Encoder.attributeEscape($SERVERVERSION)" size="10" />
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
       <nobr>$Encoder.bodyEscape($ResourceBundle.getString('ElasticSearchConnector.ServerLocation'))</nobr>
         $Encoder.bodyEscape($ResourceBundle.getString('ElasticSearchConnector.URLColon'))
     </td>
@@ -81,6 +89,7 @@
 
 #else
 
+<input type="hidden" name="serverversion" value="$Encoder.attributeEscape($SERVERVERSION)"
/>
 <input type="hidden" name="serverlocation" value="$Encoder.attributeEscape($SERVERLOCATION)"
/>
 <input type="hidden" name="indexname" value="$Encoder.attributeEscape($INDEXNAME)" />
 <input type="hidden" name="indextype" value="$Encoder.attributeEscape($INDEXTYPE)" />

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration.html?rev=1798195&r1=1798194&r2=1798195&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration.html
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration.html
Fri Jun  9 12:24:51 2017
@@ -17,6 +17,10 @@
 
 <table class="displaytable">
   <tr>
+    <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('ElasticSearchConnector.ServerVersion'))</nobr>
+    <td class="value">$Encoder.bodyEscape($SERVERVERSION)</td>
+  </tr>
+  <tr>
     <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('ElasticSearchConnector.ServerLocation'))</nobr>
     $Encoder.bodyEscape($ResourceBundle.getString('ElasticSearchConnector.URLColon'))</td>
     <td class="value">$Encoder.bodyEscape($SERVERLOCATION)</td>



Mime
View raw message