[SERVER-2819] More control over output result format Created: 23/Mar/11 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 1.8.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Brandon Dixon | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu Server 10 64-bit |
||
| Assigned Teams: |
Query Optimization
|
| Participants: |
| Description |
|
In the current state of Mongo a query will return the results intended, but also the whole structure of the document itself. This can be quite cumbersome as my ideal usage for MongoDB is to query and then take the outputted BSON to a JSON format. Having the whole document returned despite asking for a small chunk means I will need to drill down into the JSON output until I get to my actual results. What would be better is to have a generic results container document that encapsulates my results or the ability to rewrite the output format in a query-like syntax (SQL => SELECT data AS myoutput ...). To further illustrate the issue, I have included an example below. When I do a query for the following: I get the following for every document in my collection:
What would be ideal is something like:
|
| Comments |
| Comment by Asya Kamsky [ 03/Apr/18 ] |
|
Aggregation framework and its projection syntax is able to do that transformation before the data is returned from the server. |
| Comment by jp [ 14/May/11 ] |
|
I agree there should be more control over retrieval of embedded documents...when I index the subdocs and query for an object who contains 100's of subdocs, but I really only need to retrieve the one that satisfies the query. This should function at any depth within the embedding. |
| Comment by Andrew Armstrong [ 19/Apr/11 ] |
|
+1, would be nice to be able to just deal with the embedded document on its own when querying. This is especially useful if you have a list of embedded documents in a container document, and you want to pick out a few of the container documents (and load them as strongly typed with say C# generics) and only have to deal with the embedded documents. |
| Comment by Brandon Dixon [ 23/Mar/11 ] |
|
Apologies on the details being messed up. |