You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/11/15 20:02:31 UTC

[GitHub] [nifi] ChrisSamo632 commented on a change in pull request #4153: NIFI-6403: Adding Elasticsearch7 support to HTTP processors

ChrisSamo632 commented on a change in pull request #4153:
URL: https://github.com/apache/nifi/pull/4153#discussion_r523806123



##########
File path: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-processors/src/main/java/org/apache/nifi/processors/elasticsearch/AbstractElasticsearchHttpProcessor.java
##########
@@ -343,11 +375,48 @@ protected void buildBulkCommand(StringBuilder sb, String index, String docType,
         } else if (indexOp.equalsIgnoreCase("delete")) {
             sb.append("{\"delete\": { \"_index\": \"");
             sb.append(StringEscapeUtils.escapeJson(index));
-            sb.append("\", \"_type\": \"");
-            sb.append(StringEscapeUtils.escapeJson(docType));
-            sb.append("\", \"_id\": \"");
+            sb.append("\"");
+            if (!(StringUtils.isEmpty(docType) | docType == null)){
+                sb.append(", \"_type\": \"");
+                sb.append(StringEscapeUtils.escapeJson(docType));
+                sb.append("\"");
+            }
+            sb.append(", \"_id\": \"");
             sb.append(StringEscapeUtils.escapeJson(id));
-            sb.append("\" }\n");
+            sb.append("\" }}\n");
+        }
+    }
+
+    protected String getFieldIncludeParameter(ElasticsearchVersion esVersion) {
+        return esVersion.equals(ElasticsearchVersion.ES_LESS_THAN_7)
+                ? FIELD_INCLUDE_QUERY_PARAM : FIELD_INCLUDE_QUERY_PARAM_ES7;
+    }
+
+    static class ElasticsearchTypeValidator implements Validator {
+        private boolean pre7TypeRequired;
+
+        /**
+         * Creates a validator for an ES type
+         * @param pre7TypeRequired If true, 'type' will be required for ES
+         * before version 7.0.
+         */
+        public ElasticsearchTypeValidator(boolean pre7TypeRequired) {
+            this.pre7TypeRequired = pre7TypeRequired;
+        }
+
+        @Override
+        public ValidationResult validate(String subject, String input, ValidationContext context) {
+            ElasticsearchVersion esVersion = ElasticsearchVersion.valueOf(context
+                    .getProperty(ES_VERSION).getValue());
+            if (esVersion == ElasticsearchVersion.ES_7) {
+                return new ValidationResult.Builder().valid(org.apache.commons.lang3.StringUtils.isBlank(input) || "_doc".equals(input))

Review comment:
       `_source` is also Valid here for ES 7 in a GET document request (i.e. the Fetch processor)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org