2323import org .elasticsearch .indices .IndicesExpressionGrouper ;
2424import org .elasticsearch .logging .LogManager ;
2525import org .elasticsearch .logging .Logger ;
26- import org .elasticsearch .transport .RemoteClusterAware ;
2726import org .elasticsearch .xpack .esql .VerificationException ;
2827import org .elasticsearch .xpack .esql .action .EsqlExecutionInfo ;
2928import org .elasticsearch .xpack .esql .action .EsqlQueryRequest ;
@@ -363,7 +362,7 @@ public void analyzedPlan(
363362 initializeClusterData (indices , executionInfo );
364363
365364 var listener = SubscribableListener .<EnrichResolution >newForked (
366- l -> enrichPolicyResolver .resolvePolicies (getEnrichTargets ( executionInfo ), unresolvedPolicies , executionInfo , l )
365+ l -> enrichPolicyResolver .resolvePolicies (unresolvedPolicies , executionInfo , l )
367366 )
368367 .<PreAnalysisResult >andThen ((l , enrichResolution ) -> resolveFieldNames (parsed , enrichResolution , l ))
369368 .<PreAnalysisResult >andThen ((l , preAnalysisResult ) -> resolveInferences (preAnalysis .inferencePlans , preAnalysisResult , l ));
@@ -389,12 +388,6 @@ public void analyzedPlan(
389388 }).<PreAnalysisResult >andThen ((l , result ) -> {
390389 assert requestFilter != null : "The second pre-analysis shouldn't take place when there is no index filter in the request" ;
391390
392- // "reset" execution information for all ccs or non-ccs (local) clusters, since we are performing the indices
393- // resolving one more time (the first attempt failed and the query had a filter)
394- for (String clusterAlias : executionInfo .clusterAliases ()) {
395- executionInfo .swapCluster (clusterAlias , (k , v ) -> null );
396- }
397-
398391 // here the requestFilter is set to null, performing the pre-analysis after the first step failed
399392 preAnalyzeIndices (preAnalysis .indices , executionInfo , result , null , l );
400393 }).<LogicalPlan >andThen ((l , result ) -> {
@@ -412,15 +405,6 @@ public void analyzedPlan(
412405 }).addListener (logicalPlanListener );
413406 }
414407
415- private static Set <String > getEnrichTargets (EsqlExecutionInfo executionInfo ) {
416- Set <String > targetClusters = executionInfo .getClusters ().keySet ();
417- if (targetClusters .isEmpty ()) {
418- // Always include local cluster for enrich resolution
419- return Set .of (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY );
420- }
421- return targetClusters ;
422- }
423-
424408 private void preAnalyzeLookupIndex (IndexPattern table , PreAnalysisResult result , ActionListener <PreAnalysisResult > listener ) {
425409 Set <String > fieldNames = result .wildcardJoinIndices ().contains (table .indexPattern ()) ? IndexResolver .ALL_FIELDS : result .fieldNames ;
426410 // call the EsqlResolveFieldsAction (field-caps) to resolve indices and get field types
0 commit comments