[SERVER-974] $subset query operator Created: 06/Apr/10 Updated: 06/Dec/22 Resolved: 09/Mar/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Andrea Fontana | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Done | Votes: | 14 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Description |
|
Example collection:
There's no way to get element that match a subset of an array.
to extract all object except the last one (that contains '4'). It's something similar to a reversed $all operator... |
| Comments |
| Comment by Asya Kamsky [ 09/Mar/18 ] | ||||||||||
|
Now that 3.6 has $expr this can be done via $setIsSubset expression in query. | ||||||||||
| Comment by Asya Kamsky [ 05/Feb/18 ] | ||||||||||
|
There are two ways to do this currently:
| ||||||||||
| Comment by Nick Gerner [ 17/Feb/11 ] | ||||||||||
|
any movement on support for this? | ||||||||||
| Comment by Michael Stephens [ 07/Aug/10 ] | ||||||||||
|
The included test case (jstests/subset.js) does still pass with an indexed field. I've never delved into mongo's query optimization code, but I'll try to see if I can get a little understanding of it and how to make $subset work with it (if it's not already) later. | ||||||||||
| Comment by Eliot Horowitz (Inactive) [ 07/Aug/10 ] | ||||||||||
|
The biggest problem with the patch is that it doesn't work with the query optimizer. | ||||||||||
| Comment by Michael Stephens [ 07/Aug/10 ] | ||||||||||
|
Any comments on my patch? | ||||||||||
| Comment by Michael Stephens [ 29/May/10 ] | ||||||||||
|
I took an initial stab at implementing this, see http://github.com/mikejs/mongo/commit/5555757d0354a9991ec8fe4bae498d2bd69a250d – I'm sure it can be improved on, but it works on the supplied test cases. |