Mongo-hadoop connector: how to request data

I am using the hadoop mongo connector in java (spark application). I did a mongo db reading by setting this configuration

Configuration mongodbConfig = new Configuration();
mongodbConfig.set("mongo.job.input.format", "com.mongodb.hadoop.MongoInputFormat");
mongodbConfig.set("mongo.input.uri", "mongodb://localhost:27017/MyCollectionName.collection");

What can be added to request data (for example .limit(100000))

+4
source share
1 answer

You can add additional parameters to the configuration Example:

mongodbConfig.set("mongo.input.query", "{'field':'value'}");

see https://github.com/mongodb/mongo-hadoop/wiki/Configuration-Reference for more details

+2
source

Source: https://habr.com/ru/post/1616766/


All Articles