Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How do I perform the following update using PUT_MONGO

How do I perform the following update using PUT_MONGO

New Contributor

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?

1 REPLY 1

Re: How do I perform the following update using PUT_MONGO

New Contributor

PutMongo does not like my $or


110041-1563907840335.png




110003-1563908090277.png


1563907857447.png