Github user zenfenan commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2560#discussion_r175278403
  
    --- Diff: 
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
 ---
    @@ -169,14 +208,16 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
                     // update
                     final boolean upsert = 
context.getProperty(UPSERT).asBoolean();
                     final String updateKey = 
context.getProperty(UPDATE_QUERY_KEY).getValue();
    +                final String updateQuery = 
context.getProperty(UPDATE_QUERY).evaluateAttributeExpressions(flowFile).getValue();
    +                final Document query;
     
    -                Object keyVal = ((Map)doc).get(updateKey);
    -                if (updateKey.equals("_id") && 
ObjectId.isValid(((String)keyVal))) {
    -                    keyVal = new ObjectId((String) keyVal);
    +                if (!StringUtils.isBlank(updateKey)) {
    +                    query = parseUpdateKey(updateKey, (Map)doc);
    +                    removeUpdateKeys(updateKey, (Map)doc);
    +                } else {
    +                    query = Document.parse(updateQuery);
    --- End diff --
    
    Shall we change it to `filterQuery` ? Purely a cosmetic change, feel free 
to ignore it but I think it follows a better naming convention since it's 
actually a *filter* query based on which the update is done.


---

Reply via email to