[SERVER-737] $allOrdered / $contains query operations for arrays Created: 11/Mar/10 Updated: 06/Dec/22 Resolved: 28/Jan/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Harry Marr | Assignee: | Backlog - Query Execution |
| Resolution: | Won't Do | Votes: | 1 |
| Labels: | nc | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Execution
|
||||||||
| Participants: | |||||||||
| Description |
|
It could be helpful to provide a new operator, similar to $all for arrays, that matches an ordered subset of items: db.test.insert( {'actions': [2, 6, 3, 8, 5, 3]}); ); A couple of use cases:
Also, allowing it to be optionally anchored to the start or end of an array would open up more possibilities:
|
| Comments |
| Comment by Asya Kamsky [ 09/Mar/18 ] | ||||||||
|
There's a blog post explaining how the above works and showing how to do non-strict ordered subset match also: http://www.kamsky.org/stupid-tricks-with-mongodb/how-to-match-a-strict-subset-of-an-array-in-order | ||||||||
| Comment by Asya Kamsky [ 29/Jun/17 ] | ||||||||
|
For the record, this is how:
| ||||||||
| Comment by Asya Kamsky [ 29/Jun/17 ] | ||||||||
|
This is possible to do in aggregation framework using array expressions, but that's only helpful if this use case is for analytics. |