[JAVA-2235] Multiple $match filters in BSON for aggregator Created: 29/Jun/16 Updated: 11/Sep/19 Resolved: 29/Jun/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API, BSON |
| Affects Version/s: | 3.2.2 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Critical - P2 |
| Reporter: | PRDP | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver, query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java 1.8, Java MongoDB driver v3.2.2, MongoDB 3.0.11 |
||
| Description |
|
I'm running with below aggregation where in match condition will be added depending upon selected filter Bson empIdMatch = new BasicDBObject(); empIdMatch = match(eq("empId",1234567)); // mandatory value - empId List<Bson> pipeline = asList(detailsUnwind,empIdMatch,deptIdMatch,gradeMatch); AggregateIterable<Document> aggresult = collection.aggregate(pipeline); for (Document documet : aggresult) { } If i level is not available, than i'm getting - This is what i want to achieve Case 1) When both Department and Level details are available Case 2) When only Grade is available |
| Comments |
| Comment by Ross Lawley [ 29/Jun/16 ] |
You must only include pipeline stages that actually perform an operation - so you cannot have empty stages. Do not include empty documents in your pipeline list. 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 mailing list or stackoverflow as you will reach a boarder audience there. If your business requires an answer from MongoDB within a set time frame then we do offer production support. |