Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2287#discussion_r161784589
--- Diff:
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-5-processors/src/main/java/org/apache/nifi/processors/elasticsearch/PutElasticsearch5.java
---
@@ -212,18 +224,38 @@ public void process(final InputStream in) throws
IOException {
String json = IOUtils.toString(in, charset)
.replace("\r\n", " ").replace('\n', '
').replace('\r', ' ');
- if (indexOp.equalsIgnoreCase("index")) {
-
bulk.add(esClient.get().prepareIndex(index, docType, id)
-
.setSource(json.getBytes(charset)));
- } else if (indexOp.equalsIgnoreCase("upsert"))
{
-
bulk.add(esClient.get().prepareUpdate(index, docType, id)
- .setDoc(json.getBytes(charset))
- .setDocAsUpsert(true));
- } else if (indexOp.equalsIgnoreCase("update"))
{
-
bulk.add(esClient.get().prepareUpdate(index, docType, id)
- .setDoc(json.getBytes(charset)));
- } else {
- throw new IOException("Index operation: "
+ indexOp + " not supported.");
+ switch(indexOp.toLowerCase()) {
+ case "index": {
+ if
(version != null) {
+
bulk.add(esClient.get().prepareIndex(index, docType, id)
+
.setVersion(version).setVersionType(VersionType.EXTERNAL)
--- End diff --
What happens when version is null (i.e. the property is left blank or the
Expression resolves to nothing)? Should we only call setVersion() and
setVersionType() if version != null? That would ensure that the default
(internal) versioning is used unless otherwise provided here.
---