@@ -566,16 +566,17 @@ private void resolveIndicesAndAnalyze(
566566 PreAnalysisResult result ,
567567 ActionListener <Versioned <LogicalPlan >> logicalPlanListener
568568 ) {
569- SubscribableListener .<PreAnalysisResult >newForked (l -> preAnalyzeMainIndices (preAnalysis , executionInfo , result , requestFilter , l ))
570- .andThenApply (r -> {
571- if (r .indexResolution .isEmpty () == false // Rule out ROW case with no FROM clauses
572- && executionInfo .isCrossClusterSearch ()
573- && executionInfo .getRunningClusterAliases ().findAny ().isEmpty ()) {
574- LOGGER .debug ("No more clusters to search, ending analysis stage" );
575- throw new NoClustersToSearchException ();
576- }
577- return r ;
578- })
569+ SubscribableListener .<PreAnalysisResult >newForked (
570+ l -> preAnalyzeMainIndices (preAnalysis , configuration , executionInfo , result , requestFilter , l )
571+ ).andThenApply (r -> {
572+ if (r .indexResolution .isEmpty () == false // Rule out ROW case with no FROM clauses
573+ && executionInfo .isCrossClusterSearch ()
574+ && executionInfo .getRunningClusterAliases ().findAny ().isEmpty ()) {
575+ LOGGER .debug ("No more clusters to search, ending analysis stage" );
576+ throw new NoClustersToSearchException ();
577+ }
578+ return r ;
579+ })
579580 .<PreAnalysisResult >andThen ((l , r ) -> preAnalyzeLookupIndices (preAnalysis .lookupIndices ().iterator (), r , executionInfo , l ))
580581 .<PreAnalysisResult >andThen ((l , r ) -> {
581582 enrichPolicyResolver .resolvePolicies (preAnalysis .enriches (), executionInfo , l .map (r ::withEnrichResolution ));
@@ -813,6 +814,7 @@ private void validateRemoteVersions(EsqlExecutionInfo executionInfo) {
813814 */
814815 private void preAnalyzeMainIndices (
815816 PreAnalyzer .PreAnalysis preAnalysis ,
817+ Configuration configuration ,
816818 EsqlExecutionInfo executionInfo ,
817819 PreAnalysisResult result ,
818820 QueryBuilder requestFilter ,
@@ -842,7 +844,16 @@ private void preAnalyzeMainIndices(
842844 forAll (
843845 preAnalysis .indexes ().entrySet ().iterator (),
844846 result ,
845- (e , r , l ) -> preAnalyzeFlatMainIndices (e .getKey (), e .getValue (), preAnalysis , executionInfo , r , requestFilter , l ),
847+ (e , r , l ) -> preAnalyzeFlatMainIndices (
848+ e .getKey (),
849+ e .getValue (),
850+ configuration .projectRouting (),
851+ preAnalysis ,
852+ executionInfo ,
853+ r ,
854+ requestFilter ,
855+ l
856+ ),
846857 listener
847858 );
848859 }
@@ -883,6 +894,7 @@ private void preAnalyzeMainIndices(
883894 private void preAnalyzeFlatMainIndices (
884895 IndexPattern indexPattern ,
885896 IndexMode indexMode ,
897+ String projectRouting ,
886898 PreAnalyzer .PreAnalysis preAnalysis ,
887899 EsqlExecutionInfo executionInfo ,
888900 PreAnalysisResult result ,
@@ -891,6 +903,7 @@ private void preAnalyzeFlatMainIndices(
891903 ) {
892904 indexResolver .resolveFlatWorldIndicesVersioned (
893905 indexPattern .indexPattern (),
906+ projectRouting ,
894907 result .fieldNames ,
895908 createQueryFilter (indexMode , requestFilter ),
896909 indexMode == IndexMode .TIME_SERIES ,
0 commit comments