manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1836769 - in /manifoldcf/trunk: CHANGES.txt connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
Date Fri, 27 Jul 2018 00:59:42 GMT
Author: kwright
Date: Fri Jul 27 00:59:42 2018
New Revision: 1836769

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

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1836769&r1=1836768&r2=1836769&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Fri Jul 27 00:59:42 2018
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 2.11-dev =====================
 
+CONNECTORS-1518: Elastic search without mapper attachment
+did not stream document.
+(Steph van Schwalk)
+
 CONNECTORS-1514: Fix MCF Combined Service UI
 (Kishore Kumar)
 

Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java?rev=1836769&r1=1836768&r2=1836769&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
(original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
Fri Jul 27 00:59:42 2018
@@ -204,22 +204,50 @@ public class ElasticSearchIndex extends
           Base64 base64 = new Base64();
           base64.encodeStream(inputStream, pw);
           pw.print("\"}");
+          needComma = true;
         }
         
         if (!useMapperAttachments && inputStream != null) {
           if (contentAttributeName != null)
           {
             Reader r = new InputStreamReader(inputStream, Consts.UTF_8);
-            StringBuilder sb = new StringBuilder((int)document.getBinaryLength());
+            if (needComma) {
+              pw.print(",");
+            }
+            pw.append(jsonStringEscape(contentAttributeName)).append(" : \"");
             char[] buffer = new char[65536];
             while (true)
             {
               int amt = r.read(buffer,0,buffer.length);
               if (amt == -1)
                 break;
-              sb.append(buffer,0,amt);
+              for (int j = 0; j < amt; j++) {
+                final char x = buffer[j];
+                if (x == '\n')
+                  pw.append('\\').append('n');
+                else if (x == '\r')
+                  pw.append('\\').append('r');
+                else if (x == '\t')
+                  pw.append('\\').append('t');
+                else if (x == '\b')
+                  pw.append('\\').append('b');
+                else if (x == '\f')
+                  pw.append('\\').append('f');
+                else if (x < 32)
+                {
+                  pw.append("\\u").append(String.format(Locale.ROOT, "%04x", (int)x));
+                }
+                else
+                {
+                  if (x == '\"' || x == '\\' || x == '/')
+                    pw.append('\\');
+                  pw.append(x);
+                }
+              }
             }
-            needComma = writeField(pw, needComma, contentAttributeName, new String[]{sb.toString()});
+            
+            pw.append("\"");
+            needComma = true;
           }
         }
         



Mime
View raw message