[SERVER-14670] Add expressions to determine the length of a string Created: 24/Jul/14 Updated: 22/Mar/17 Resolved: 29/Mar/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 3.3.4 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Lukas Benes | Assignee: | Benjamin Murphy |
| Resolution: | Done | Votes: | 15 |
| Labels: | expression | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||
| Sprint: | Query 12 (04/04/16) | ||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Githook User [ 29/Mar/16 ] | ||
|
Author: {u'username': u'benjaminmurphy', u'name': u'Benjamin Murphy', u'email': u'benjamin_murphy@me.com'}Message: | ||
| Comment by Benjamin Murphy [ 29/Mar/16 ] | ||
|
This patch adds the $strLenCP and $strLenBytes aggregation expressions, with syntax as described in the description, which need to be documented and added to any drivers that support aggregation helpers. | ||
| Comment by Charlie Swanson [ 11/Mar/16 ] | ||
|
After some internal discussion, I've updated the description to reflect the agreed-upon design. | ||
| Comment by Asya Kamsky [ 02/Oct/15 ] | ||
|
To add $length we need to decide if it returns length in UTF8 bytes or Unicode code points. I think the important issue is that its size should match the way $substr counts since $length can be used in an expression to get values for $substr. | ||
| Comment by Bradley Arsenault [ 11/Jun/15 ] | ||
|
I second a strong desire for a $length operator for strings. It is useful in a variety of circumstances I have encountered. I would find it useful in the following forms: 1) As a query operator to match strings of a specific length or strings greater/less then a specific length. | ||
| Comment by Asya Kamsky [ 25/Jul/14 ] | ||
|
I understand the number of characters before '#' is variable, but if that number is bounded (for example less than 20) then you can use the trick I describe here: | ||
| Comment by David Moravek [ 25/Jul/14 ] | ||
|
We need to select six characters from the middle of string with variable length and use them as a group _id. So we ended up with the following $project:
document _id we subtract string from looks like this: 1234567#201410T-02 (length of the number followed by hashmark varies) it would be awesome if we could simply write something like this:
| ||
| Comment by Asya Kamsky [ 25/Jul/14 ] | ||
|
davidmoravek what is the reason that you need $length (since you mention $substr) - is it to somehow normalize a string value? | ||
| Comment by David Moravek [ 24/Jul/14 ] | ||
|
Hari, the reason we need the $length operator, is that $substr does not support negative offset (because of string::size_type data type). Is there any other way to achieve this? Thanks | ||
| Comment by hari.khalsa@10gen.com [ 24/Jul/14 ] | ||
|
Thanks for the diff, falsecz. I think we're going to postpone this until we can consider the agg projection language in a more holistic fashion. |