Support Questions
Find answers, ask questions, and share your expertise

NiFi GetMongoRecord Schema

NiFi GetMongoRecord Schema

New Contributor

Good day. I'm using NiFi 1.12.0, and my task is to get a set of previously unknown number of records from MongoDB. As GetMongo processor can either write each record to a separate FlowFile, or combine a defined number of records in one file, I decided to use the GetMongoRecord processor to get a JSON array regardless of how many records are returned by the query.


For testing, I set my query to {“x”: 123} with projection {"x": 1}, knowing that is should return an array with two elements [{"x":123}, {"x":123}]. I've created an AvroSchemaRegistry with the following schema:


"type": "record",
"name": "test",

"fields": [ {"name": "x", "type": ["null", "long"]} ]


I use this schema in GetMongoRecord and in JsonRecordSetWriter through the "Schema Name" parameter. And as a result I get a FlowFile with an empty array [] in its contents.


I have a feeling that I'm missing some fundamental point about schemas and writers in this particular case. Could anyone please help make sense of it?