[JAVA-2915] how to implement nested query in java API Created: 22/Jul/18 Updated: 03/Apr/23 Resolved: 23/Jul/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | jacky chen | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
db.a.find({ "id" : { "$in" : ["3", "5"] }}) for this query, I just create a filter like below bson object which is workable. new BasicDBObject("id", new BasicDBObject("$in", new String[] {"3", "5"]));
db.a.find({ "id" : { "$in" : db.b.distinct("id") }}) for this second query, is there a way to create a BasicDBObject for filter object. I mean how to express nested query body, db.b.distinct("id"), in BasicDBObject. |
| Comments |
| Comment by Ross Lawley [ 23/Jul/18 ] |
|
Hi update0412, I believe the $lookup aggregation pipeline is what you require. Just to let you know this project is for Java driver bugs or feature requests. The best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there. If your business requires an answer from MongoDB within a time frame then we do offer production support. If you do follow up via one of the options above please post a link and I will follow the conversation there. All the best, Ross |