Support Questions

Find answers, ask questions, and share your expertise

What is the key to use in PutMongo to Update/Upsert

avatar
Rising Star

I have a sequence of flowfiles that I need to put to mongo. A sample is at the bottom of this question. The flowfile contains JSON with a field "evt_data": {"stdds_id": "stdds_id_value" ..


I need that stdds_id_value to be the key for update/upsert into mongo. I'm looking for help with the flow configuration that will make this work.


My current PutMongo (non-working attempt) configuration is this:



110028-1563990877147.png


I'm trying to put a record that is keyed on the evt_data.stdds_id value as see in the following flowfile JSON:

110037-1563990980491.png


In other words the key for the document in Mongo would be

"TARGET-STDDS-KCLT-157481920517"


This doesnt work, and I end up seeing multiple documents in mongo for that same key. I should only see one per distinct key.


What is the proper way to set the update key?

3 REPLIES 3

avatar
Rising Star

By the way, (if I need to) I am able to use EvaluateJSONPath to extract the stdds_id and place it as an attribute on the flowfile (see STDDS_ID) :

110029-1563995731565.png

Id use STDDS_ID as the key into mongo, but I'm not sure how to add this to the flowfile content, so that I can update/upsert using this key.

avatar
Rising Star

I've verified that if the key is set to a field that is in the root level of my JSON then I am able to update/upsert properly.


For example, I tried this with the evt_type field:


110045-1563996491699.png


This worked fine. So my only question is how do I handle a field that is one level down in the JSON

as is the case with stdds_id

{"evt_data": {"stdds_id": "stdds_id_value" , ...}}

avatar
Explorer

 Hi

 

for this flow 

can you share what was teh content of the flow file. and what was the configuration in put mongo. 

 

I am facing the same issues. 

 

Thanks

Rupesh