Mongo Hadoop - Passing date in mongo.input.query

262 views
Skip to first unread message

Alan B

unread,
Jun 11, 2013, 8:02:26 AM6/11/13
to mongod...@googlegroups.com
I am working with Hadoop to write Map Reduce jobs for my application.

I found I could set query condition before the job gets executed by editing the property `mongo.input.query`.

But when I tried to give the below query (added ISODate for MongoDB concern)

      <property>
        <name>mongo.input.query</name>
        <value>{ "created_at": { "$gt": ISODate("2013-06-12") } }</value>
        <value></value>
      </property>

Actually this query ({ "created_at": { "$gt": ISODate("2013-06-12") } }) works fine when running in MongoVUE query console, but when running with a Hadoop job it shows like 

    java.lang.IllegalArgumentException: Provided JSON String is not representable/parseable as a DBObject.
    Caused by: com.mongodb.util.JSONParseException:
    { "created_at": { "$gt": ISODate("2013-06-12") } }

Any suggestion would be helpful to resolve this.

Thanks.

Mike O'Brien

unread,
Jun 11, 2013, 4:54:10 PM6/11/13
to mongod...@googlegroups.com

Use extended json for Dates and other datatypes which aren't part of native JSON. For example:

 {"created_at":{"$gt":{"$date":1182470400000}}}

(using the long representation of the date).

Alan B

unread,
Jun 12, 2013, 3:48:16 AM6/12/13
to mongod...@googlegroups.com
I tried to pass this when running hadoop job hadoop jar path_to_jar.jar -Dmongo.input.query=' {"created_at":{"$gt":{"$date":"1370784120000"}}}' path_to_config_class, (The date refers to 2013/06/09 Sunday and I have data in db which have created at greater than this date.. but its not working 

Mike O'Brien

unread,
Jun 12, 2013, 8:53:08 AM6/12/13
to mongod...@googlegroups.com
Are you getting any error message?
If you could attach some log output from your hadoop job run, that may help us see what's going on.

Alan B

unread,
Jun 13, 2013, 6:19:11 AM6/13/13
to mongod...@googlegroups.com
Actually this isn't throwing any errors, but the query condition is not applied, and so no records are taken into account for applying map reduce.
I have data with created at greater than June 2nd 2013, but this query isn't filtering out the data after this date.

The given milli second value 1370784120000 represents Sunday June 9th 2013, you can refer this in the below link

marko...@accedo.tv

unread,
Jan 30, 2014, 11:09:41 AM1/30/14
to mongod...@googlegroups.com
Just a guess: escape the $-sign.
Reply all
Reply to author
Forward
0 new messages