[SERVER-39062] pass expression to limit of aggregation pipeline Created: 17/Jan/19 Updated: 09/Apr/19 Resolved: 18/Mar/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | yunx | Assignee: | Asya Kamsky |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Case: | (copied to CRM) |
| Description |
|
Now $limit in aggregation just support assign integer, can we pass expression to it? |
| Comments |
| Comment by Asya Kamsky [ 18/Mar/19 ] |
|
It is not possible for the pipeline to know in advance how many documents there will be and therefore we do not support $limit syntax that would be able to compute a portion of all possible results. A workaround for the application would be to separately get an approximate (or exact) count of documents and then pass an explicit limit that's calculated (client-side) based on that value.
|
| Comment by Asya Kamsky [ 16/Feb/19 ] |
|
yunx do you mean you wanted 1/3 of total number of results? Or does result_size value something that's known and you just wanted to be able to do division? |
| Comment by yunx [ 14/Feb/19 ] |
|
Hi, I wanted to get 1/3 or any percent of aggregation results, not a special number, so I assigned 1/3 * results_size to $limit, but it was not supported. |
| Comment by Asya Kamsky [ 06/Feb/19 ] |
|
yunx if you can express limit in {$limit:<number>} as an expression then many optimizations that aggregation pipeline currently uses would not be possible. Can you describe the use case or give some specific examples you have in mind that require being able to limit by another field in the document or computed expression? |
| Comment by Danny Hatcher (Inactive) [ 22/Jan/19 ] |
|
Hello, Thanks for the report. I have passed this ticket to our Query team to take a look. Thank you, Danny |