takotsubo
takotsubo

Reputation: 746

Nifi: Filter flow files by content

I have about 2000 flow files from REST API calls in json format. One file looks like:

[ {
  "manager_customer_id" : 637,
  "resourceName" : "customers/673/customerClients/3158981",
  "clientCustomer" : "customers/3158981",
  "hidden" : false,
  "level" : "2",
  "manager" : false,
  "descriptiveName" : "Volvo",
  "id" : "3158981"
} ]

Now i want to filter them by parameter manager. If manager is true, i should skip this flow file. So i need to work with flow files where manager is false. How to do this with Apache Nifi?

Upvotes: 1

Views: 1852

Answers (2)

Pdeuxa
Pdeuxa

Reputation: 699

You can convert your flowfile, to a record with the help of ConvertRecord. It allows to pass to an Json format to whatever you prefer, you can still keep Json format.

But with your flowfile beeing a record you can now use additionnal processors like: QueryRecord, so you can run SQL like command on the flow file:

"SELECT * FROM FLOWFILE WHERE manager=true"

I recommand you the following readings:

Upvotes: 2

Frankenstine Joe
Frankenstine Joe

Reputation: 313

You can just use EvaluateJSONPath (to store the value of manager in attribute) and Route on attribute ( to filter based on that attribute), Direct the flow from Manager=true to auto terminate and proceed with the rest to success.

Upvotes: 1

Related Questions