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

NiFi PutMongo with Dates

NiFi PutMongo with Dates

New Contributor

Hi,

 

I am running into some serious JSON validation errors, which is not really needed when I am trying to insert records into MongoDB, which expects "Extended JSON". This is when I am trying to use PutMongo Processor!

 

Here is the scenario:

I have a input CSV like this:

bpno,age,ordered
1234,12,"24.10.2017"

 

Through a series of processors, i got it formatted to the shape that is as expected by MongoDB update statement.
{$set: {"createdon": ISODate("2017-03-03"),"bpno": "1234","age":"12","ordered":"xyz"}}

 

PutMongo is failing to update this statement, because ISODate is not complying to Standard JSON! (com.mongodb.util.JSONParseException) I have reached a dead end here, due to this!

 

Is there a way we can relax this insert this record with Date field?

Any solution or alternate approach, is really appreciated!

 

Here is the screenshot of PutMongo

Mongo_Error.JPG

(PS: PutMongoRecord works fine, when we use appropriate AVRO schema, with date annotation. In my case mentioned above, i need to do an update, hence using PutMongo)

1 REPLY 1

Re: NiFi PutMongo with Dates

Contributor

try this

"createdon" : {
"$date" : "putInHereDate"
}

instead of 

"createdon": ISODate("2017-03-03")

you can solve this also via JOLT