[
https://issues.apache.org/jira/browse/NIFI-12224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17871135#comment-17871135
]
ASF subversion and git services commented on NIFI-12224:
--------------------------------------------------------
Commit c5ed5c51e93f5b1f9311b5a478e64b2f1320a9d4 in nifi's branch
refs/heads/main from Umar Hussain
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=c5ed5c51e9 ]
NIFI-12224 Added Support for updateMany Method in PutMongo
This closes #8610
Signed-off-by: David Handermann <[email protected]>
> PutMongo: Add support for updateMany operation with operators enabled option
> ----------------------------------------------------------------------------
>
> Key: NIFI-12224
> URL: https://issues.apache.org/jira/browse/NIFI-12224
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.23.2
> Reporter: Malte
> Assignee: Umar Hussain
> Priority: Minor
> Time Spent: 2h 40m
> Remaining Estimate: 0h
>
> Problem to solve: In my case, I wanted to add a field to a couple of
> documents that fullfill a certain condition. The [PutMongo
> documentation|https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-mongodb-nar/1.23.0/org.apache.nifi.processors.mongodb.PutMongo/additionalDetails.html]
> states that if you select the "With Operators Enabled" mode, then the
> "Update Query" property can be used "to find one or more documents to
> update". But the processor uses the ["updateOne" method of the
> MongoCollection
> class|https://github.com/apache/nifi/blob/22ad7d542d627e767f962b13236da90a0d6410f5/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java#L230C21-L230C41],
> which will only update the first match.
> Proposed solutions:
> 1. Update the documentation to correctly state that only one document (the
> first match) can be updated using an operator.
> 2. Use the updateMany method of the MongoCollection class.
> 3. Add a property like ["update-mode" from
> PutMongoRecord|https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-mongodb-nar/1.23.0/org.apache.nifi.processors.mongodb.PutMongoRecord/]
> to switch between updateOne and updateMany.
> Workaround: Right now I use the RunMongoAggregation and use a $match,
> $addFields and $merge operation to achieve what I want. But I think the
> PutMongo processor would be the intuitive way to go.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)