Search code examples
apache-nifi

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?


Solution

  • 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: