-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-3726: Add support for $sampleRate match expression. #3765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-3726: Add support for $sampleRate match expression. #3765
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reluctant introducing another abstraction for $sampleRate
. We should find a better representation. Right now, $sampleRate
is applicable to aggregations only, while the mentioned $rand
operators works in normal queries. I anticipate that sooner or later, $sampleRate
would be officially allowed as criteria operator. MongoDB 4.4. accepts already $sampleRate
via db.getCollection(…).find({$sampleRate:0.33})
.
Therefore, I'd ask you to update this pull request to introduce a sampleRate
operator to the Criteria
type. Doing so would significantly reduce complexity of this change.
* @return new instance of {@link MatchOperation}. | ||
* @since 3.2.4 | ||
*/ | ||
public static MatchOperation match(MatchExpression matchExpression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not introduce another abstraction.
Hi @mp911de Thanks for the review. Makes sense, will update implementation to use Criteria 👍 Should have some time this weekend. |
Add support for Pattern. Extract Regex flags translation from Criteria into RegexFlags utility class. Add since and author tags. Simplify tests. Update reference documentation. See spring-projects#3725. Original pull request: spring-projects#3781.
caff79f
to
a40d15c
Compare
a40d15c
to
8c0fe2c
Compare
@mp911de Hey Mark, have had another crack at it. Hope I have not missed anything 🙈 Thanks! |
Thanks a lot. That looks good. I'm taking this PR from here. |
Thank you for your contribution. That's merged and polished now. |
Closes #3726
Hey 👋, hope this implementation is good, this new
$sampleRate
expression threw me a little as it looks like the first one we have that can only be applied within the match pipeline stage and is not available outside of aggregation (so not aCriteria
).