[
https://issues.apache.org/jira/browse/NIFI-4625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16327214#comment-16327214
]
ASF GitHub Bot commented on NIFI-4625:
--------------------------------------
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.
> Add External Versioning to PutElasticSearch5 Processor
> ------------------------------------------------------
>
> Key: NIFI-4625
> URL: https://issues.apache.org/jira/browse/NIFI-4625
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Core Framework
> Affects Versions: 1.3.0
> Environment: All
> Reporter: Pedro Gomes
> Assignee: Pedro Gomes
> Priority: Major
> Labels: elasticsearch, processor
> Original Estimate: 48h
> Remaining Estimate: 48h
>
> Currently the PutElasticSearch5 processor does not support external
> versioning.
> The idea would be to add a property that follows the same logic as the Id
> property, and allows index documents with an externally controlled version.
> I've changed the code already and added some tests. Right now the changes
> proposed are:
> - Add a new property Version in the processor block.
> - Change the Index operation to support the versioning number and versioning
> type = external
> - Check if the versioning is used with other operation types, fail if so.
> (Idea behind this is that the bulk api doest not support external versioning
> for any other operation except Index)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)