[
https://issues.apache.org/jira/browse/NIFI-4989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16403882#comment-16403882
]
ASF GitHub Bot commented on NIFI-4989:
--------------------------------------
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.
> PutMongo cannot specify nested fields or multiple lookup keys
> -------------------------------------------------------------
>
> Key: NIFI-4989
> URL: https://issues.apache.org/jira/browse/NIFI-4989
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Mike Thomsen
> Assignee: Mike Thomsen
> Priority: Major
>
> From the user mailing list:
> {quote}{color:#222222}I am using PutMongo processor to update documents in a
> mongoDB collection.{color}
> {color:#222222}I would like to specify nested field and multiple key in the
> update Key.{color}
> {color:#222222}For exemple :{color}
> {color:#222222}- my mongodb documents are {"nom":"HAMEL",
> "prenom":"Yves",{color}
> {color:#222222}"ids":\{"idSoc":"1234", "idInterne":"788"}}{color}
> {color:#222222}- I would'd like to set update query key to something like
> {"ids.idSoc" ,{color}
> {color:#222222}"nom"}{color}
> {color:#222222}- this would means that I update document with ids.idSoc and
> nom equals to{color}
> {color:#222222}my mew document.{color}
> {quote}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)