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.

Nifi PutMongo - How to insert document into MongoDB using attribute values of Flow File but not Flow File content?

Solved Go to solution
Highlighted

Nifi PutMongo - How to insert document into MongoDB using attribute values of Flow File but not Flow File content?

New Contributor

I am trying to insert a document into mongodb using apache NiFi. I want to insert a document just from Flow File attributes but not the Flow File content.

I have tried using PutMongo processor but it insert the content of the Flow file which I don't want it to insert. I need to insert a custom document by using the flow file's attributes.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Nifi PutMongo - How to insert document into MongoDB using attribute values of Flow File but not Flow File content?

Master Guru
@Vishwanath Joshi

There are several processors you can use to write the attributes values to the content of the FlowFile which you can then send using putMongo processor. Here are a few examples

-

ReplaceText processor - You can use this to replace all content with the values from one or more FlowFile attributes using the NiFi expression language in the "Replacement Value" configuration property and the "Always replace" configuration option.

-

AttributesToJson processor - You use a Java regular expression to identify which FlowFile attributes will be used to generate json content and destination configuration of "flowfile content".

-

AttributesToCSV processor - You use a Java regular expression to identify which FlowFile attributes will be used to generate csv content and destination configuration of "flowfile content".

-

*** Link to details on NiFi Expression Language:

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

-

Thank you,

Matt

-

If you found this answer addressed your question, please take a moment to login in and click the "ACCEPT" link.

1 REPLY 1

Re: Nifi PutMongo - How to insert document into MongoDB using attribute values of Flow File but not Flow File content?

Master Guru
@Vishwanath Joshi

There are several processors you can use to write the attributes values to the content of the FlowFile which you can then send using putMongo processor. Here are a few examples

-

ReplaceText processor - You can use this to replace all content with the values from one or more FlowFile attributes using the NiFi expression language in the "Replacement Value" configuration property and the "Always replace" configuration option.

-

AttributesToJson processor - You use a Java regular expression to identify which FlowFile attributes will be used to generate json content and destination configuration of "flowfile content".

-

AttributesToCSV processor - You use a Java regular expression to identify which FlowFile attributes will be used to generate csv content and destination configuration of "flowfile content".

-

*** Link to details on NiFi Expression Language:

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

-

Thank you,

Matt

-

If you found this answer addressed your question, please take a moment to login in and click the "ACCEPT" link.

Don't have an account?
Coming from Hortonworks? Activate your account here