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

    https://github.com/apache/nifi/pull/2560#discussion_r175296639
  
    --- Diff: 
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
 ---
    @@ -196,6 +237,33 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
             }
         }
     
    +    private void removeUpdateKeys(String updateKeyParam, Map doc) {
    +        String[] parts = updateKeyParam.split(",[\\s]*");
    +        for (String part : parts) {
    +            if (part.contains(".")) {
    --- End diff --
    
    For this input:
    
    ```
    {
        "name": "John Smith",
        "department": "Engineering"
    }
    ```
    
    It makes no sense to remove `name` if we're doing a full document update 
using the `name key.
    
    Now consider this complex document:
    
    ```
    {
        "name": "John Smith",
        "department": "Engineering",
        "contacts": {
             "email": "[email protected]"
         }
    }
    ```
    
    To search on `email`, we have to submit this payload with the lookup key 
being `contacts.email`:
    
    ```
    {
        "contacts.email": "[email protected]",
        "name": "John Smith",
        "department": "Engineering",
        "contacts": {
             "email": "[email protected]"
         }
    }
    ```
    
    Mongo cannot do a lookup using this: `{ "contacts": { "email": 
"[email protected]" }}`
    
    So if we don't remove the complex lookup key, we are leaving extraneous 
information in the document that almost certainly has no value to the user.
    
    Now maybe we'll get an angry ticket complaining that they can't do periods 
in the key names, but I've never seen normal use cases where developers do 
that. The whole idea of creating complex key names for real data using periods 
and such flies in the face of how JSON is supposed to work.


---

Reply via email to