[ https://issues.apache.org/jira/browse/BEAM-6241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16725996#comment-16725996 ]
Ahmed El.Hussaini edited comment on BEAM-6241 at 12/20/18 4:23 PM: ------------------------------------------------------------------- [~iemejia] already did. This is the GitHub PR [https://github.com/apache/beam/pull/7293.] I totally agree about refactoring the query building part using a more organized and generic way. I’ve made a few changes to this class which I currently use internally and the comment I left for myself is… {code:java} // Need a better way to build the cursor object // Ugh, really Ugh!{code} I guess there’re two approaches here. One is to refactor the query building piece using DBObjects. The other is to use an external dependency ( ex: [https://github.com/MorphiaOrg/morphia] ). Here is what I can do. I'll open a new Ticket/PR to refactor the query building piece and decouple that piece from the main Source and Sink API. was (Author: sandboxws): [~iemejia] already did. This is the GitHub PR [https://github.com/apache/beam/pull/7293.] I totally agree about refactoring the query building part using a more organized and generic way. I’ve made a few changes to this class which I currently use internally and the comment I left for myself is… ``` // Need a better way to build the cursor object // Ugh, really Ugh! ``` I guess there’re two approaches here. One is to refactor the query building piece using DBObjects. The other is to use an external dependency ( ex: https://github.com/MorphiaOrg/morphia ). Here is what I can do. I'll open a new Ticket/PR to refactor the query building piece and decouple that piece from the main Source and Sink API. > MongoDbIO - Add Limit and Aggregates Support > -------------------------------------------- > > Key: BEAM-6241 > URL: https://issues.apache.org/jira/browse/BEAM-6241 > Project: Beam > Issue Type: Improvement > Components: io-java-mongodb > Affects Versions: 2.9.0 > Reporter: Ahmed El.Hussaini > Assignee: Jean-Baptiste Onofré > Priority: Major > Labels: easyfix > Fix For: 2.10.0 > > > h2. Adds Support to Limit Results > > {code:java} > MongoDbIO.read() > .withUri("mongodb://localhost:" + port) > .withDatabase(DATABASE) > .withCollection(COLLECTION) > .withFilter("{\"scientist\":\"Einstein\"}") > .withLimit(5));{code} > h2. Adds Support to Use Aggregates > > {code:java} > List<BsonDocument> aggregates = new ArrayList<BsonDocument>(); > aggregates.add( > new BsonDocument( > "$match", > new BsonDocument("country", new BsonDocument("$eq", new > BsonString("England"))))); > PCollection<Document> output = > pipeline.apply( > MongoDbIO.read() > .withUri("mongodb://localhost:" + port) > .withDatabase(DATABASE) > .withCollection(COLLECTION) > .withAggregate(aggregates)); > {code} > -- This message was sent by Atlassian JIRA (v7.6.3#76005)