[SERVER-5320] Make $elemMatch support single object Created: 15/Mar/12 Updated: 09/Jul/16 Resolved: 07/Mar/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.1.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Zefei Xuan | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
Currently $elemMatch only supports array values, so queries such as {foo: {$elemMatch: {a:1, b:2}}} will match {foo:[ {a:1, b:2, c:3}]}, but not {foo: {a:1, b:2, c:3}}. I know this can be easily done by query {'foo.a':1, 'foo.b':2}, but this behavior is inconsistent with other query operations; e.g. {a:1}will match both {a:[1]}and {a:1}. I'm currently writing a DSL for mongo, and I find it hard to explain this inconsistency to users. But I don't know if changing this will affect query optimizer. |