- Notifications
You must be signed in to change notification settings - Fork 25.6k
Min score for time series #96878
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
Min score for time series #96878
Conversation
Enables min score on time series aggregation.
| @martijnvg might need some more checkstyle cleanup, but should essentially be ready for review. |
| Pinging @elastic/es-analytics-geo (Team:Analytics) |
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.
Thanks for working on this.
I left a few comments.
| Scorer scorer = weight.scorer(leaf); | ||
| if (scorer != null) { | ||
| LeafWalker leafWalker = new LeafWalker(leaf, scorer, bucketCollector, () -> tsidOrd[0]); | ||
| LeafWalker leafWalker = new LeafWalker(leaf, scorer, minimumScore, bucketCollector, () -> tsidOrd[0]); |
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.
What about wrapping the scorer here with a MinScoreScorer wrapper?
The DocIdSetIterator it produces in the LeafWalker constructor only returns documents that have at least the minimum score.
This way LeafWalker class doesn't need to be changed and there shouldn't be any overhead for users not using the minimum score feature?
| this.timestampReverse = TIME_SERIES_SORT[1].getOrder() == SortOrder.DESC; | ||
| } | ||
| | ||
| public void setMinimumScore(float minimumScore) { |
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.
This does need to be invoked from AggregationPhase otherwise it minimum score functionality can't be used?
...rc/test/java/org/elasticsearch/search/aggregations/support/TimeSeriesIndexSearcherTests.java Show resolved Hide resolved
| @martijnvg should we ready to go now! I'll be around for a while on slack if there's any last minute changes we need. |
This looks almost ready. Can you address this comment: https://github.com/elastic/elasticsearch/pull/96878/files#r1234034640 I think we just need to wrap the scorer before we create the |
| dir.close(); | ||
| } | ||
| | ||
| static class StaticScoreFunctionBuilder extends ScoreFunctionBuilder<StaticScoreFunctionBuilder> { |
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.
And this inner class can be removed? Because it is no longer used?
| Hi @tmgordeeva, I've created a changelog YAML for you. |
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.
Left one comment, otherwise LGTM
| private final SortedNumericDocValues timestamps; // TODO can we have this just a NumericDocValues? | ||
| private final BytesRefBuilder scratch = new BytesRefBuilder(); | ||
| | ||
| private final Scorer scorer; |
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 think this field is no longer used and can be removed?
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.
Oops, I missed this comment - I'll make a tiny cleanup PR later.
Enables min score on time series aggregation.