Mongo node: problem querying for dates with jongo

I need to query some information from Mongo based on a date and and timestamp. I have been using the mongo node for a while always for simpler queries like {a:10}, e.g. For the  docs i need to retrieve the console query would be something similar to:

 db.audio.find({'d':{"$gt": new Date("01/11/2017")}})

After reading the jongo documentation and google, it seems that the way of querying for dates in jongo is something like this, using templates:

collection.find("{date: {$lt : #}}", new Date(2012, 11, 30));

However, anytime that i try this or any variation into knime query box:

"{date: {$lt : #}}", new Date(2012, 11, 30) 

I got this error: 

Not enough parameters passed to query.

And if i even try the jongo documentation examples, like  "{name:#, age:#}", "Joe", 18 i got the same error, just like templates are not supported.

Can anyone point me into the right direction  with a couple of working examples to directly put into the Mongo node query field, of working with dates (selecting all documents in a range of dates or before/after a date)?

Thanks very much

Emilio

 

 

Hello Emilio,

unfortunately the MongoDB node currently does not support parameters like they are required for this query. Currently all values have to be inlined in the query. Off the top of my head I cannot think of an elegant solution for this problem. Maybe this feature will be added in future releases, but as far as I know is currently not on the roadmap. However, I will file a request for it because I think this would be a great improvement for the MongoDB nodes.

Regards,

Alexander

1 Like

Hi Alexander

Thanks very much for your answer, it would be indeed a great improvement for processing time series data, otherwise the Node is useless as you can not process all the collection data in one query  every time you want updated information.

I have been tipped towards launching the query withing Knime using Python node, which i will post here if i find out  a good solution for this.

I used a Python Edit Variable to create a well-formatted query flow variable. However, no matter how I try to build the date portion of the query, I either get no results or a parser error. Were you able to get around this? Also linking back to Frustrated with Mongo and knime and Querying Dates in MongoDB Reader