Skip to content

[Star Tree] Support of Boolean Queries in Aggregations #17941

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

Merged
merged 40 commits into from
Apr 28, 2025

Conversation

imRishN
Copy link
Member

@imRishN imRishN commented Apr 14, 2025

Description

This PR adds support for boolean queries in star tree indices. The implementation handles both MUST and SHOULD clauses with specific constraints to maintain star tree's performance benefits.

Key Changes:

  1. Added BoolStarTreeFilterProvider to handle boolean queries
  2. Implemented DimensionFilterMerger for handling filter intersections
  3. Recursive support for nested bool queries

Constraints

  1. MUST clause
    • Basic MUST Constraints:
      • Can operate across different dimensions (e.g., status=200 AND method=GET)
      • Each dimension can appear only once after combining
      • Multiple conditions on same dimension are logically impossible (e.g., status=200 AND status=404)
      • Supports term, terms, and range queries
    • Nested MUST Interaction:
      • Can have multiple levels of nesting
      • All conditions are treated as AND operations
      • When same dimension appears in nested levels:
        • Need to find intersection of conditions
        • Return null if intersection is empty
        • Example: status>=200 AND (status<300) = 200<=status<300
    • MUST + SHOULD Interaction:
      • MUST conditions take precedence over top-level SHOULD
      • When containing SHOULD clauses:
        • SHOULD clauses become required conditions
        • Must process SHOULD conditions first (union)
        • Then intersect with other MUST conditions if on same dimension
        • Handle as separate dimension if on different dimension
    • Dimension Handling:
      • Each dimension can appear only once in final result
      • Must intersect conditions when same dimension appears in different clauses
      • Must maintain ordinal-based comparisons for each dimension
      • Return null if any dimension's conditions result in empty intersection
  2. SHOULD clause
    • Basic SHOULD Constraints:
      • All SHOULD clauses must operate on same dimension
      • Only term, terms, and range queries allowed directly in SHOULD
      • Cannot have SHOULD clauses across different dimensions (no cross-dimension OR)
    • MUST + SHOULD Interaction:
      • Top-level SHOULD with MUST is optional (affects score only unless minimum_should_match is set)
      • When SHOULD is inside a MUST clause:
        • Acts as a required condition (minimum_should_match = 1 implicitly)
        • If operating on same dimension as outer MUST: Need to find union of SHOULD conditions first and then intersect with outer MUST conditions
        • If operating on different dimension than outer MUST: Process normally as a required condition
    • Nested SHOULD Constraints:
      • Nested SHOULD clauses must all operate on same dimension as parent SHOULD
      • All levels of nesting must maintain single dimension constraint
      • Should be flattened during processing
    • Nested Bool in SHOULD:
      • Cannot have MUST clauses inside SHOULD (no multi-dimension combinations, same dimension combination is still possible)
      • Cannot have MUST_NOT clauses
      • Only nested SHOULD on same dimension allowed

Related Issues

Resolves #17267

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.

Copy link
Contributor

❌ Gradle check result for 525e2d2: 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 9dbe1bf: 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?

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for 1adb472: 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?

Signed-off-by: Rishab Nahata <[email protected]>
@imRishN imRishN changed the title Support of Boolean Queries in Aggregations by Star-Tree Support of Boolean Queries in Aggregations by StarTree Apr 18, 2025
@imRishN imRishN changed the title Support of Boolean Queries in Aggregations by StarTree Support of Boolean Queries in Aggregations by Star Tree Apr 18, 2025
@imRishN imRishN changed the title Support of Boolean Queries in Aggregations by Star Tree [Star Tree] Support of Boolean Queries in Aggregations Apr 18, 2025
Copy link
Contributor

❌ Gradle check result for 0d22537: 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?

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for 308c3c9: 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?

imRishN added 2 commits April 19, 2025 03:34
Signed-off-by: Rishab Nahata <[email protected]>
Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for ac34a73: 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?

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for 5a0ecf1: 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?

imRishN added 2 commits April 20, 2025 19:29
Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for 4cb1f66: 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?

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for c937541: 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?

imRishN added 2 commits April 20, 2025 22:31
Signed-off-by: Rishab Nahata <[email protected]>
Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for b508ea6: 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?

Signed-off-by: Rishab Nahata <[email protected]>
imRishN added 2 commits April 25, 2025 12:54
Signed-off-by: Rishab Nahata <[email protected]>
Signed-off-by: Rishab Nahata <[email protected]>
@imRishN
Copy link
Member Author

imRishN commented Apr 25, 2025

Lets please add issues for union, must not and possible support for should across dimensions use cases to track them. This PR looks good for me.

#18080
#18079
#18081

Copy link
Contributor

❕ Gradle check result for 2596863: 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.

Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 85.05155% with 29 lines in your changes missing coverage. Please review.

Project coverage is 72.49%. Comparing base (6ce0628) to head (63b786d).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...tartree/filter/provider/DimensionFilterMapper.java 48.27% 3 Missing and 12 partials ⚠️
...ee/filter/provider/BoolStarTreeFilterProvider.java 89.02% 4 Missing and 5 partials ⚠️
...ch/startree/filter/DimensionFilterMergerUtils.java 94.66% 1 Missing and 3 partials ⚠️
...search/search/startree/filter/DimensionFilter.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17941      +/-   ##
============================================
- Coverage     72.61%   72.49%   -0.13%     
+ Complexity    67203    67190      -13     
============================================
  Files          5473     5475       +2     
  Lines        310145   310339     +194     
  Branches      45064    45122      +58     
============================================
- Hits         225225   224976     -249     
- Misses        66576    66998     +422     
- Partials      18344    18365      +21     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❕ Gradle check result for fa3382c: 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.

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for 4cbf846: 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?

Signed-off-by: Rishab Nahata <[email protected]>
Copy link
Contributor

❌ Gradle check result for 63b786d: 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?

@imRishN
Copy link
Member Author

imRishN commented Apr 28, 2025

@expani does this PR looks good to you now?

Copy link
Contributor

✅ Gradle check result for 63b786d: SUCCESS

@sachinpkale sachinpkale merged commit 74a67c9 into opensearch-project:main Apr 28, 2025
31 of 32 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 3.0 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-3.0 3.0
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-3.0
# Create a new branch
git switch --create backport/backport-17941-to-3.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 74a67c9851f5c214886096d5ee76c8b63fdeece8
# Push it to GitHub
git push --set-upstream origin backport/backport-17941-to-3.0
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-3.0

Then, create a pull request where the base branch is 3.0 and the compare/head branch is backport/backport-17941-to-3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 3.0 backport-failed enhancement Enhancement or improvement to existing feature or request Search:Aggregations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Star Tree] [Search] Support of Boolean Queries in Aggregations supported by Star-tree
4 participants