Support Questions
Find answers, ask questions, and share your expertise

How do I perform the following update using PUT_MONGO

I need to do an update/upsert into Mongo.


Essentially the command that I need to run is seen in the following command (this works in the mongo command line client):


110011-1563903146075.png


Notice in the first update I search for the document that matches the specified STDDS_DST_ID. In the second update, I match any of several Ids including the one that was already matched. In this simple example. I have a set of linked Ids: TFM_ID, FVIEW_ID, STDDS_DST_ID. The set of linked IDs is unique. For in this example that per-set distinction guarantees that you wont find STDDS_DIST_ID 100 associated with another FVIEW_ID, or TFM_ID. You'll only find it with FVIEW_ID 3000 and TFM_ID 300000.


So assuming that I have a flowfile that contains some number of fields (e.g. fld1, fld2, fl3), and one or more of the ids: TFM_ID, STDDS_DST_ID, FVIEW_ID, how can I configure PutMongo so that it will update/upsert the appropriate document (that one that matches one or more of these IDs)?


Again, in my mind, PutMongo simply needs to be configured consistent with the update you see in the image above. I just dont have much experience with PutMongo.


110021-1563903512126.png




110031-1563903890129.png

Looking at the documentation, I believe I must do the following:

  1. Set Mode to update
  2. Set Upsert to true
  3. Leave Update Query Key Empty
  4. Set the Update Query to something such as the first argument in the sample command:
  5. { $or: [{"TFM_ID": "300000"}, {"FVIEW_ID": "3000"},{"STDDS_DST_ID": "100"}]}
  6. Set the flowfile content to the data to place in the document (including the $set):
  7. {$set: {"fld2": "fld2_val", "fld3": "fld3_val", "TFM_ID": "300000", "FVIEW_ID": "3000","STDDS_DST_ID": "100"}}

Are my assumptions on the mark?

3 REPLIES 3

PutMongo does not like my $or


110041-1563907840335.png




110003-1563908090277.png


1563907857447.png

New Contributor

Hi,

You need just to put your $or between quotes : 

{
    "$or":
    [
        {
            "TFM_ID": "300000"
        },
        {
            "FVIEW_ID": "3000"
        },
        {
            "STDDS_DST_ID": "100"
        }
    ]
}

 

 

Community Manager

Hi @M-Boufnichel as this is an older post, you would have a better chance of receiving a resolution by starting a new thread. This will also be an opportunity to provide details specific to your environment that could aid others in assisting you with a more accurate answer to your question. You can link this thread as a reference in your new post.



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:
; ;