[SERVER-391] Support both include and exclude on field filters Created: 28/Oct/09 Updated: 07/Apr/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Mathias Stearn | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 16 |
| Labels: | QFB, asya | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Optimization
|
||||||||
| Participants: | |||||||||
| Description |
|
find({}, {a:1, b.c:0}) |
| Comments |
| Comment by David Storch [ 19/May/17 ] | |||
|
asya, interesting observation that this can now be achieved in the aggregation framework with sequential projection stages. I'd like to keep this open, however, since I think in the future we may want to design a more elegant way to express this kind of document transformation within a single aggregation stage. | |||
| Comment by Asya Kamsky [ 15/May/17 ] | |||
|
Do we really need this? Assuming we merge projection and aggregation $project stage, I think there will be ways to get the thing described in the initial description?
| |||
| Comment by Ezequiel Primo [ 21/Jan/15 ] | |||
|
Hello, these are some tests that I have been doing concerning this issue: > db.test.findOne() , { "child_name" : "Anna" } ] And at the moment of executing the following queries: > db.test.find( {"family" : "Smith"}, {"children" : 1, "family" : 0,"_id":0}) , {"children" : 0, "family" : 1 ,"_id":0}) , {"children" : 0, "family" : 1 ,"_id":1}) , {"children" : 0, "family" : 0 ,"_id":1}) In this case for instance the result is fine: > db.test.find( {"family" : "Smith"}, {"children" : 1, "family" : 1 ,"_id":0}) , { "child_name" : "Anna" }] } | |||
| Comment by Antonio Quintana [ 10/Jan/14 ] | |||
|
Hi! I've got this error. My case is the following:
| |||
| Comment by NOVALUE Mitar [ 15/Nov/13 ] | |||
|
My use case is: Publications.find( {'importing.person._id': personId}, {'importing.$': 1, 'importing.$.temporaryFile': 0}) So I would like to get only that subdocument of importing belonging to the person, but remove temporaryFile field in those subdocument. | |||
| Comment by Justin Dearing [ 18/Oct/10 ] | |||
|
The message this currently generates is: db.events.findOne(null, {_id:1, Name:1, "Locations":1, "Locations.v.Dates": 0}) Mon Oct 18 12:23:27 uncaught exception: error { | |||
| Comment by Justin Dearing [ 18/Oct/10 ] | |||
|
See http://groups.google.com/group/mongodb-user/browse_thread/thread/c53d99916e46ae1a/d4a79a34104377f9#d4a79a34104377f9 for commentary. |