[ 
https://issues.apache.org/jira/browse/NIFI-2135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15352971#comment-15352971
 ] 

Bryan Bende commented on NIFI-2135:
-----------------------------------

PutMongo does the following for an update:

{code}
else {
    // update
    final boolean upsert = context.getProperty(UPSERT).asBoolean();
    final String updateKey = context.getProperty(UPDATE_QUERY_KEY).getValue();
    final Document query = new Document(updateKey, doc.get(updateKey));

    collection.replaceOne(query, doc, new UpdateOptions().upsert(upsert));
    logger.info("updated {} into MongoDB", new Object[] { flowFile });
}
{code}

We should be using the collection.updateOne() instead of replaceOne().

> PutMongo replacing document instead of updating document
> --------------------------------------------------------
>
>                 Key: NIFI-2135
>                 URL: https://issues.apache.org/jira/browse/NIFI-2135
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 0.6.1
>            Reporter: Bryan Bende
>            Priority: Minor
>
> How can I use put mongo processor to add a new key value pair to an existing 
> document? The flow file contains the document object Id. I have set 'mode' 
> property to 'update' and 'upsert' property to false and 'update query key' 
> property to '_id'. Flow file content is something like this.
> {
> _id:ObjectId(577216f0154b943fe8068079)
> expired:true
> }
> Without inserting the 'expired:true', it replaces the whole document with the 
> given one. So is there  a way to  insert the new key value pair to collection 
> without replacing the whole collection in MongoDB using putmongo processor? 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to