[JAVA-2471] aggregation on view doesn't work Created: 16/Mar/17 Updated: 04/Apr/17 Resolved: 04/Apr/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Query Operations |
| Affects Version/s: | 3.4.2 |
| Fix Version/s: | 3.5.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | adrien petel | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
ubuntu 16.04, single mongod instance, no shard, no replica set. Used along with spring-data-mongodb 1.10.1 |
||
| Attachments: |
|
| Description |
|
Aggregation on view doesn't work when run with java driver, but works fine in shell. sample code to reproduce the issue:
Error shows up with both Cursor and AggregationOutput stack trace: Exception in thread "main" org.bson.BsonInvalidOperationException: Document does not contain key result |
| Comments |
| Comment by Githook User [ 04/Apr/17 ] | |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: | |
| Comment by Ross Lawley [ 16/Mar/17 ] | |
|
felix2626, having discussed internally, we think we can improve the current the experience in the next release (3.5.0). I'll also update the type from bug to improvement. | |
| Comment by Ross Lawley [ 16/Mar/17 ] | |
|
As in the driver can't tell if the underlying collection is a view and because the inline results are being deprecated. I'm marking this as won't fix. | |
| Comment by Ross Lawley [ 16/Mar/17 ] | |
|
This is a side effect of how views work, aggregations returned from views always come back as cursors. However, in the legacy API it defaults to inline results and this is why you are seeing an error. Inline results for the aggregate command were deprecated in the server for MongoDB 3.4 and will be removed in MongoDB 3.6 ( By default in 3.4.2 DBCollection.aggregate(pipeline) sets the output mode to be OutputMode.INLINE and this is the cause of the error. The work done in
Will fix the issue. I attached a test case showing the issue succeeds when using the cursor output mode but fails with the default. Ross |