Created 02-14-2019 04:41 PM
I am trying to get all documents within a time range using RunMongoAggreation.
In console I tried with below query and it worked fine.
db.collection.find( { "header.timestamp": { $gte: ISODate("2018-12-20T05:19:35.904Z"), $lt: ISODate("2018-12-20T05:21:44.509Z") } } )
Flowfile has below properties
startTimestamp: 2018-12-20T05:19:35.904Z
endTimestamp: 2018-12-20T05:21:44.509Z
Below is the query being used in RunMongoAggreation
{ "header.timestamp": { "$gt": { "$date": "${startTimestamp}" }, "$lt": { "$date": "${endTimestamp}" } } }
Its not working gettting below exception
com.fasterxml.jackson.databind.exc.mismatchedinputexception cannot deserialize instance of `java.util.arraylist` out of START_OBJECT token
Created 06-17-2021 11:03 PM
Convert field to timestamp then compare.
[
{
"$addFields": {
"timestamp": {
"$toLong": "$header.timestamp"
}
}
},
{
"$match": {
"timestamp": {
"$gte": ${startTimestamp:toDate("yyyy-MM-dd HH:mm:ss"):toNumber()}
},
"timestamp": {
"$lte": ${endTimestamp:toDate("yyyy-MM-dd HH:mm:ss"):toNumber()}
}
}
},
{
"$project": {
"timestamp": 1
}
}
]
Created 06-18-2021 03:21 AM
Hello!
Try to use flow UpdateAttribute - GetMongo.
To UpdateAttribute create attr with value
{
"header.timestamp": {
"$gt": {
"$date": "${startTimestamp}"
},
"$lt": {
"$date": "${endTimestamp}"
}
}
}
To GetMongo in field Query insert name attr from prev step.
RunMongoAggreation used for aggregation query, but select all docs is not effective, I think.