Add multi-index support for DSL search queries - #23069
ask-kamal-nayan wants to merge 1 commit into
Conversation
PR Reviewer Guide 🔍(Review updated until commit 090665f)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 090665f
Previous suggestionsSuggestions up to commit 4ea4ba2
|
|
❌ Gradle check result for 4ea4ba2: QUEUE_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? |
…e gate Signed-off-by: Kamal <askkamal@amazon.com>
4ea4ba2 to
090665f
Compare
|
Persistent review updated to latest commit 090665f |
|
❌ Gradle check result for 090665f: QUEUE_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? |
Description
Adds multi-index support to the DSL DataFusion path, for both hits and aggregations. A
_searchagainst N indices (comma list, wildcard, alias, or data stream) now resolves, plans, executes, and renders correctly. When all indices agree on a referenced field, results match single-index behaviour; when they genuinely disagree, the request fails with HTTP 400 instead of returning wrong matches or garbled buckets. All new logic is a no-op at N==1 (single-index path byte-identical, no feature flag).Why: resolution previously hard-required exactly one concrete index. Relaxing that is unsafe on its own — the schema builder unions indices first-wins with no conflict detection and collapses distinct OpenSearch types onto one Calcite type, so divergent fields surface as wrong query literals and wrong bucket keys, neither raising an error today.
What changes:
MultiIndexResolutionStrategy— sibling toSingleIndexResolutionStrategy; resolves to an orderedList<IndexMetadata>instead of throwing when count != 1. Selected unconditionally byTransportExecuteAction/TransportValidateAction.RequestScopedMapperService— widened to an ordered index list with first-non-null field lookup and lazy per-index mapper construction (handles split fields with no reject rule).SchemaEquivalenceGate— two-concern gate, post-conversion / pre-execution, scoped to fields the resolved plan references (RexInputRef), compared atMappedFieldTypegranularity:keyword/long,ip/keyword). Governs hits and predicates, not just aggs.TermsResponseStrategy.forType(typeName)+docValueFormat+ a per-type discriminator (scaled_float factor, keyword normalizer,date/date_nanos, float precision). Catches same-Calcite-type splits the conversion gate can't see. Metrics RAW-exempt. Format equality via.equals()with aRAWfast-path.expand_wildcards=open,hiddencase where vanilla silently drops the filter (a confirmed tenant-leak). Documented divergence from vanilla.resolveExpressions(ClusterState, IndicesOptions, String...)— additiveIndexNameExpressionResolveroverload so the guard resolves under the request's own options. No existing signature changes.State.OPENbefore their properties union into the schema.Testing: unit
dsl-query-executor568/0,analytics-engine1070/0, server resolver 77/0. Live E2E on a running cluster covering expression forms,IndicesOptions, both gates (incl. the discriminator holes), phantom-column exclusion, filtered/hidden-alias guards, split-field resolution, hits, and aggregation types — verified to reject genuine divergence and not over-reject equivalents (keyword≡text, identical factor/normalizer); empty resolution returns a clean empty 200.Known limitations: (1) a pre-existing broad whole-mapping check in shared
IndexResolution(unmodified here) fires before the scoped gate and over-rejects on divergence in an unreferenced field. (2)scaled_floatwith divergent factors used as a metric returns a wrong sum — metrics are RAW-exempt and this is a separate pre-existing single-index engine bug, not introduced or fixed here.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.