Skip to content
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

[Star Tree] [Search] Keyword & Numeric Terms Aggregation #17165

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sandeshkr419
Copy link
Contributor

@sandeshkr419 sandeshkr419 commented Jan 28, 2025

Description

Related Issues

Resolves #16551

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions github-actions bot added enhancement Enhancement or improvement to existing feature or request Search:Aggregations labels Jan 28, 2025
@sandeshkr419 sandeshkr419 added backport 2.x Backport to 2.x branch v2.19.0 Issues and PRs related to version 2.19.0 and removed enhancement Enhancement or improvement to existing feature or request Search:Aggregations labels Jan 28, 2025
Copy link
Contributor

@bharath-techie bharath-techie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Sandesh for the changes. LGTM as changes are mostly similar to date histo aggs.

Copy link
Contributor

❌ Gradle check result for 89310be: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

✅ Gradle check result for 89310be: SUCCESS

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 84.68468% with 17 lines in your changes missing coverage. Please review.

Project coverage is 72.43%. Comparing base (b82ed5a) to head (e1bebaa).

Files with missing lines Patch % Lines
...ket/terms/GlobalOrdinalsStringTermsAggregator.java 81.81% 3 Missing and 5 partials ⚠️
...regations/bucket/terms/NumericTermsAggregator.java 90.19% 1 Missing and 4 partials ⚠️
...ensearch/search/startree/StarTreeQueryContext.java 78.57% 1 Missing and 2 partials ⚠️
...rch/aggregations/bucket/terms/TermsAggregator.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17165      +/-   ##
============================================
+ Coverage     72.29%   72.43%   +0.13%     
- Complexity    65699    65783      +84     
============================================
  Files          5318     5318              
  Lines        305676   305786     +110     
  Branches      44350    44374      +24     
============================================
+ Hits         220992   221494     +502     
+ Misses        66582    66125     -457     
- Partials      18102    18167      +65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

❕ Gradle check result for 89310be: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@sandeshkr419
Copy link
Contributor Author

@msfroh Rebased against your aggregation restructuring changes and incorporated the new interfaces in this PR as well. :D

Copy link
Contributor

❌ Gradle check result for 06a2ba3: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

✅ Gradle check result for 9b4da43: SUCCESS

@sandeshkr419 sandeshkr419 force-pushed the k1 branch 2 times, most recently from 1674736 to 1b0a6b9 Compare February 4, 2025 19:49
Signed-off-by: Sandesh Kumar <[email protected]>
Copy link
Contributor

github-actions bot commented Feb 4, 2025

❕ Gradle check result for e1bebaa: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@sandeshkr419
Copy link
Contributor Author

@msfroh @bharath-techie Rebased from main again since #17239 is merged.

@@ -228,6 +243,10 @@ protected boolean tryPrecomputeAggregationForLeaf(LeafReaderContext ctx) throws
(ord, docCount) -> incrementBucketDocCount(collectionStrategy.globalOrdToBucketOrd(0, ord), docCount)
);
}
CompositeIndexFieldInfo supportedStarTree = StarTreeQueryHelper.getSupportedStarTree(this.context.getQueryShardContext());
if (supportedStarTree != null) {
return preComputeWithStarTree(ctx, supportedStarTree);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precomputeWithStarTree always returns true.


String metricName = StarTreeUtils.fullyQualifiedFieldNameForStarTreeMetricsDocValues(
starTree.getField(),
"_doc_count",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hard-coded? Should it be DocCountFieldMapper.NAME?

Comment on lines +349 to +353
public void setSubCollectors() throws IOException {
for (Aggregator aggregator : subAggregators) {
this.subCollectors.add(((StarTreePreComputeCollector) aggregator).getStarTreeBucketCollector(ctx, starTree, this));
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this below the fields defined below? Fields within an anonymous class are kind of confusing, but when they are interspersed with methods, it hurts my brain.

Actually, if you move the fields out of the anonymous class declaration and into the getStarTreeBucketCollector method body, they'll get captured by the anonymous StarTreeBucketCollector anyway (and IMO, the code would be easier to read). Maybe give that a shot and see how it looks to you.

};
}

private boolean preComputeWithStarTree(LeafReaderContext ctx, CompositeIndexFieldInfo supportedStarTree) throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably return void, since we've already decided that we will precompute.

) throws IOException {
assert parent == null;
StarTreeValues starTreeValues = StarTreeQueryHelper.getStarTreeValues(ctx, starTree);
return new StarTreeBucketCollector(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty similar to the one in GlobalOrdinalsStringTermsAggregator. Is there opportunity to pull the common logic into an abstract base class?

Comment on lines +294 to +298
// don't defer when StarTreeContext is set, don't defer when collectMode == SubAggCollectionMode.BREADTH_FIRST
// this boolean condition can be further simplified but affects readability.
return (context.getQueryShardContext().getStarTreeQueryContext() == null || collectMode != SubAggCollectionMode.BREADTH_FIRST)
&& collectMode == SubAggCollectionMode.BREADTH_FIRST
&& !aggsUsedForSorting.contains(aggregator);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be:

if (context.getQueryShardContext().getStarTreeQueryContext() == null) {
  return false;
} else {
  return collectMode == SubAggCollectionMode.BREADTH_FIRST && !aggsUsedForSorting.contains(aggregator);
}

That is, make it even more complicated for readability. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch enhancement Enhancement or improvement to existing feature or request Search:Aggregations v2.19.0 Issues and PRs related to version 2.19.0
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[Star Tree] [Search] Bucket terms Aggregation with metric aggregation
3 participants