[SERVER-9090] Expand on the capabilities of "limit" to be able to limit each branch/clause of a $or & $in independently of one another Created: 22/Mar/13  Updated: 27/Dec/16  Resolved: 15/Jun/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Osmar Olivo Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-8566 Create a "limit per match" option for... Closed
Participants:

 Description   

Allow for the different clauses in $or & $in queries to limit their respective result sets.

I.E. something like

find ( { a : {$in : [ val1, val2, val3, val4, val5] } }).limit(5)

should allow me to have an option to get 5 results back for each value in the array. and then maybe set a hard limit of 25 to cap my total resultSet.



 Comments   
Comment by Asya Kamsky [ 27/Dec/16 ]

In case anyone finds this ticket while looking to do something similar, this can be achieved for some cases using aggregation pipeline with $facet (providing separate clauses to match and limit each facet and then merging the results with $concatArrays expression afterwards).

Comment by David Storch [ 15/Jun/15 ]

We do not currently plan to provide the ability to provide a mechanism for attaching a limit to individual $or clauses or individual $in elements. Closing as "Won't Fix".

Generated at Thu Feb 08 03:19:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.