Route numeric and date queries through DV branch on pluggable-datafor… - #22580
Route numeric and date queries through DV branch on pluggable-datafor…#22580aggarwalmayank wants to merge 3 commits into
Conversation
…mat indices Composite (pluggable-dataformat) indices write no BKD for numeric or date fields on the Lucene secondary. IndexOrDocValuesQuery's cost-based dispatch picks the empty point side (cost=0) and returns zero hits for range, term, terms, and bitmap queries. Introduce QueryShardContext.isPluggableDataFormatEnabled() as a null-safe gate. NumberFieldType and DateFieldType consult this gate: on Mustang-backed indices they treat the field as not-searchable so range/term/terms/bitmap queries build the pure doc-values branch that resolves against codec-served DV columns. Non-pluggable-dataformat indices retain isSearchable() behavior unchanged, preserving the BKD fast path. Extends NumberFieldType.bitmapQuery to take a QueryShardContext so it can consult the same gate. Updates the one caller in TermsQueryBuilder and the Mockito stub in TermQueryWithDocIdAndQueryTests. Adds unit tests in NumberFieldTypeTests, DateFieldTypeTests, and QueryShardContextTests covering both gate states. Signed-off-by: Mayank Aggarwal <aggmayan@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit a21df7e)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to a21df7e Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 9b38118
Suggestions up to commit 367b5f8
|
|
❌ Gradle check result for 367b5f8: TIMEOUT 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? |
| */ | ||
| private static QueryShardContext mockPluggableDataFormatContext() { | ||
| QueryShardContext ctx = org.mockito.Mockito.mock(QueryShardContext.class); | ||
| org.mockito.Mockito.when(ctx.isPluggableDataFormatEnabled()).thenReturn(true); |
| boolean effectiveSearchable = isSearchable() && !(context != null && context.isPluggableDataFormatEnabled()); | ||
|
|
||
| // Not searchable (either declared, or gated off by the pluggable-dataformat check). Must have doc values. | ||
| if (!effectiveSearchable) { |
There was a problem hiding this comment.
nit: can we either remove this null check or add one on the if block below
| */ | ||
| private boolean effectiveSearchable(QueryShardContext context) { |
There was a problem hiding this comment.
For a parquet field is say somehow hasDocValues=false here https://github.com/aggarwalmayank/OpenSearch/blob/367b5f81a28cb5c49ea739c34ea814e6f181c4ab/server/src/main/java/org/opensearch/index/mapper/NumberFieldMapper.java#L332,
we fall through to return LongPoint.newExactQuery(field, v);
Can you confirm if that is alright?
There was a problem hiding this comment.
i think there BKD would silently return zero hits if it fall through that, but i don't think index creatoin with hasDocValues=false with pluggable data format index is allowed.
Address PR feedback: replace fully-qualified org.mockito.Mockito.mock/when and org.mockito.ArgumentMatchers.anyString references with static imports in NumberFieldTypeTests and DateFieldTypeTests. Signed-off-by: Mayank Aggarwal <aggmayan@amazon.com>
|
Persistent review updated to latest commit 9b38118 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #22580 +/- ##
============================================
- Coverage 71.43% 71.42% -0.02%
+ Complexity 76760 76723 -37
============================================
Files 6142 6142
Lines 357766 357799 +33
Branches 52148 52164 +16
============================================
- Hits 255581 255563 -18
- Misses 81861 81883 +22
- Partials 20324 20353 +29 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Address PR feedback: QueryShardContext is always non-null on the query execution path, so the defensive null check is unnecessary noise. Signed-off-by: Mayank Aggarwal <aggmayan@amazon.com>
|
Persistent review updated to latest commit a21df7e |
| boolean effectiveSearchable = isSearchable() && !context.isPluggableDataFormatEnabled(); | ||
|
|
||
| // Not searchable (either declared, or gated off by the pluggable-dataformat check). Must have doc values. | ||
| if (!effectiveSearchable) { |
There was a problem hiding this comment.
We would also need to cover similarly for other data types: IP, ScaledFloat, Range types (int, float double).
I was exploring for alternatives for a single place fix. Another option is changing at ApproximateScoreQuery.canApproximate() which can help to fix for all types, but this creates a fragile assumption that either doc values query or points query is passed always to this. Hence not recommending that suggestion. But if there is any other option to avoid changes at multiple places, we can do that. Or else we can continue with current approach itself.
Description
Pluggable-dataformat-parquet-backed indices write no BKD for numeric or date fields on the Lucene secondary.
IndexOrDocValuesQuery's cost-based dispatch picks the empty point side (cost=0) and returns zero hits for range, term, terms, and bitmap queries.This PR introduces
QueryShardContext.isPluggableDataFormatEnabled()and uses it inNumberFieldTypeandDateFieldTypeto route query construction through the pure doc-values branch on pluggable-dataformat-parquet-backed indices.Non-pluggable-dataformat indices retain their existing
isSearchable()behaviour — BKD fast path preserved.Changes
QueryShardContext.isPluggableDataFormatEnabled()— null-safe check that combines the feature flag (viaIndexSettings.isPluggableDataFormatEnabled()) with per-index settings.NumberFieldType.rangeQuery/termQuery/termsQuery/bitmapQuery— calleffectiveSearchable(context)which returnsfalsewhen the gate is on, routing through the pure DV branch.DateFieldType.rangeQuery— same gate applied inline (termQuery delegates through it).NumberFieldType.bitmapQuerysignature extended to takeQueryShardContextso it can consult the gate. Single caller inTermsQueryBuilderupdated.Test coverage
NumberFieldTypeTests— verifies point path on default indices, DV path on pluggable-dataformat-parquet-backed indices for range/term/terms.DateFieldTypeTests— verifies DV path on pluggable-dataformat-parquet-backed indices for date range/term.QueryShardContextTests— verifies the gate is on only when both the feature flag and index setting are on.Related Issues
Resolves #[Issue number to be closed when this PR is merged]
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.