Add bool query and minimum_should_match support to DSL query executor - #22604
Add bool query and minimum_should_match support to DSL query executor#22604ask-kamal-nayan wants to merge 2 commits into
Conversation
PR Reviewer Guide 🔍(Review updated until commit 6403717)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 6403717 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 7761f42
Suggestions up to commit 71f2752
Suggestions up to commit 7ff3be2
Suggestions up to commit 7aa5eb0
Suggestions up to commit f48e299
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22604 +/- ##
============================================
- Coverage 71.42% 71.37% -0.05%
+ Complexity 76786 76776 -10
============================================
Files 6148 6148
Lines 357980 357980
Branches 52177 52177
============================================
- Hits 255689 255511 -178
- Misses 81937 82097 +160
- Partials 20354 20372 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit e9675cb |
|
Persistent review updated to latest commit f48e299 |
|
Persistent review updated to latest commit 7aa5eb0 |
|
Persistent review updated to latest commit 7ff3be2 |
|
Persistent review updated to latest commit 71f2752 |
|
❌ Gradle check result for 71f2752: 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? |
|
Persistent review updated to latest commit 7761f42 |
… conversion (cherry picked from commit ab86d03) Signed-off-by: Kamal Nayan <askkamal@amazon.com>
…_should_match form Signed-off-by: Kamal Nayan <askkamal@amazon.com>
7761f42 to
6403717
Compare
|
Persistent review updated to latest commit 6403717 |
Description
Adds
BoolQueryTranslatorwith fullminimum_should_matchsupport to thedsl-query-executorsandbox plugin's translator registry, enabling DSLboolqueries to be converted into Calcite logical expressions for the multi-engine analytics path.What: A translator that handles
must,filter,should,must_not, and all sixminimum_should_matchgrammar variants, producingRexNodetrees that Calcite can plan and execute.Why:
boolis the composition layer of the OpenSearch DSL — without it, only isolated leaf queries (term,terms,match_all,exists) can be translated. With this PR, those leaf queries can be nested and combined, unlocking real-world compound DSL queries on the analytics path.Where:
BoolQueryTranslatorregisters inQueryRegistryFactoryalongside existing leaf translators.MinimumShouldMatchParseris a standalone utility replicating the semantics of the legacyQueries.calculateMinShouldMatch.Scope: Bool composition + MSM parsing + conjoined arithmetic form. Does not add new leaf translators or scoring semantics.
Translation Model
{"bool":{"must":[{"term":{"status":"active"}}],"should":[{"term":{"brand":"X"}},{"term":{"brand":"Y"}}]}}status = 'active'(should is optional — MSM defaults to 0 when must is present){"bool":{"should":[{"term":{"a":"1"}},{"term":{"b":"2"}},{"term":{"c":"3"}}],"minimum_should_match":"2"}}AND(OR(a='1', b='2', c='3'), GTE(CASE(a='1',1,0) + CASE(b='2',1,0) + CASE(c='3',1,0), 2))— conjoined arithmetic form, linear in clause count{"bool":{"must_not":[{"bool":{"must_not":[{"term":{"name":"val"}}]}}]}}name = 'val'— double negation eliminated: NOT(NOT(x)) → xSupported / Rejected Parameter Matrix
mustBoolQueryBuilder.doToQuerylines 243–256:Occur.MUSTfilterBoolQueryBuilder.addBooleanClausesline 262:Occur.FILTERshouldBoolQueryBuilder.addBooleanClausesline 264:Occur.SHOULDmust_notBoolQueryBuilder.addBooleanClausesline 266:Occur.MUST_NOTminimum_should_matchQueries.calculateMinShouldMatchlines 129–165adjust_pure_negativeBoolQueryBuilder.doToQueryline 338,Queries.isNegativeQuerylines 113–119,Queries.fixNegativeQueryIfNeededlines 121–130: pure-negative + false → match-none FALSE literal; all other shapes ignore the flag (no-op) becauseisNegativeQueryrequires every clause to be prohibitedboostAbstractQueryBuilder.toQuerylines 130–136:BoostQuerywrapping_nameAbstractQueryBuilder.toQuerylines 137–139: named query registrationminimum_should_matchVariant Table"2""-1""70%""-30%""2<75%""3<-1 5<50%"Conjoined
minimum_should_matchFormFor required matches strictly between 1 and the clause count, the translator emits:
CASE(pi, 1, 0)contributes 1 when its predicate is true, the sum is compared>= kTests
BoolQueryTranslatorTests.javaMinimumShouldMatchParserTests.javaDslBoolQueryIT.javabool_must_should_hits.json,bool_minimum_should_match_hits.jsonDslBoolQueryITis parked with@AwaitsFix(bugUrl = "analytics engine pipeline not E2E complete: fragment conversion + shard execution + Arrow Flight drain not yet wired"), matching sibling ITs (DslRangeQueryIT, etc.) until the DSL pipeline is wired end-to-end.Known Gaps and Divergences
term,terms,match_all,exists,boolregistered today// TODO: add other query translatorsinQueryRegistryFactory; each query type lands as its own PRfilterandmustproduce identical ANDmustscores,filterdoes notboost/_nameRelated Issues
Part of the DSL query support track for the multi-engine analytics path.
Check List
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.