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.

RunMongoAggregation with $date

RunMongoAggregation with $date

New Contributor

Hey guys!

I'm having some difficulties with RunMongoAggregation. Could you please help me ?

I've been using the other processor from Mongo, the GetMongo. This one works the way I need, but RunMongoAggregation is giving me some problems.

This is the situation:

I want to execute an aggregation in my mongo collection. First of all, I need to filter my entire collection to get the documents inside a time interval. For this, I'm using the "$date" parameter to transform my string to an ISODate type, but it look like $date is not working well (or I'm making some mistakes).

This is what I'm trying to execute in RunMongoAggregation:

{

"$match": {

"$and": [

{

"processedAt": {

"$gte": {

"$date": "2019-06-14T11:13:27.519Z"

}

}

},

{

"eventType": "CustomerSiteAcceptedOffer"

}

]

}

}

]


My collection has the following structure:


{

"when" : ISODate("2019-06-16T00:00:00.000Z"),

"processedAt" : ISODate("2019-06-14T14:48:53.287Z"),

"eventType" : "CustomerSiteAcceptedOffer",

"version" : 1,

"context" : {

"unstruct" : {},

"customer" : {

"cpf" : "x",

"cancelationReason" : "x",

"customerCode" : "1517508329",

"name" : "john"

}

}

}


And the weird point is: if I execute the following GetMongo processor query, I get the expected result:


{

"$and": [

{

"processedAt": {

"$gte": {

"$date": "2019-06-14T11:13:27.519Z"

}

}

},

{

"eventType": "CustomerSiteAcceptedOffer"

}

]

}

It looks like $date is not working, could you help me to figure out what's happening?


Thanks!

Best regards,

Bob