6060import org .opensearch .common .settings .Setting ;
6161import org .opensearch .common .settings .Setting .Property ;
6262import org .opensearch .common .unit .TimeValue ;
63- import org .opensearch .common .util .FeatureFlags ;
6463import org .opensearch .common .util .concurrent .AtomicArray ;
6564import org .opensearch .common .util .concurrent .CountDown ;
6665import org .opensearch .core .action .ActionListener ;
8786import org .opensearch .search .pipeline .SearchPipelineService ;
8887import org .opensearch .search .profile .ProfileShardResult ;
8988import org .opensearch .search .profile .SearchProfileShardResults ;
90- import org .opensearch .search .query .StreamingSearchMode ;
9189import org .opensearch .search .slice .SliceBuilder ;
9290import org .opensearch .tasks .CancellableTask ;
9391import org .opensearch .tasks .Task ;
103101import org .opensearch .transport .RemoteClusterAware ;
104102import org .opensearch .transport .RemoteClusterService ;
105103import org .opensearch .transport .RemoteTransportException ;
104+ import org .opensearch .transport .StreamTransportService ;
106105import org .opensearch .transport .Transport ;
107106import org .opensearch .transport .TransportService ;
108107import org .opensearch .transport .client .Client ;
@@ -175,8 +174,6 @@ public class TransportSearchAction extends HandledTransportAction<SearchRequest,
175174 private final ThreadPool threadPool ;
176175 final ClusterService clusterService ;
177176 final SearchTransportService searchTransportService ;
178- @ Nullable
179- final StreamSearchTransportService streamSearchTransportService ;
180177 private final RemoteClusterService remoteClusterService ;
181178 final SearchPhaseController searchPhaseController ;
182179 private final SearchService searchService ;
@@ -198,10 +195,8 @@ public TransportSearchAction(
198195 ThreadPool threadPool ,
199196 CircuitBreakerService circuitBreakerService ,
200197 TransportService transportService ,
201- @ Nullable org .opensearch .transport .StreamTransportService streamTransportService ,
202198 SearchService searchService ,
203199 SearchTransportService searchTransportService ,
204- @ Nullable StreamSearchTransportService streamSearchTransportService ,
205200 SearchPhaseController searchPhaseController ,
206201 ClusterService clusterService ,
207202 ActionFilters actionFilters ,
@@ -220,13 +215,12 @@ public TransportSearchAction(
220215 this .circuitBreaker = circuitBreakerService .getBreaker (CircuitBreaker .REQUEST );
221216 this .searchPhaseController = searchPhaseController ;
222217 this .searchTransportService = searchTransportService ;
223- this .streamSearchTransportService = streamSearchTransportService ;
224218 this .remoteClusterService = searchTransportService .getRemoteClusterService ();
225- // Register request handlers - always classic; add streaming if available
226- if (streamTransportService != null && streamSearchTransportService != null ) {
227- StreamSearchTransportService .registerStreamRequestHandler (streamTransportService , searchService );
219+ if (transportService instanceof StreamTransportService ) {
220+ StreamSearchTransportService .registerStreamRequestHandler ((StreamTransportService ) transportService , searchService );
221+ } else {
222+ SearchTransportService .registerRequestHandler (transportService , searchService );
228223 }
229- SearchTransportService .registerRequestHandler (transportService , searchService );
230224 this .clusterService = clusterService ;
231225 this .searchService = searchService ;
232226 this .indexNameExpressionResolver = indexNameExpressionResolver ;
@@ -1147,21 +1141,11 @@ private void executeSearch(
11471141 }
11481142 }
11491143 final DiscoveryNodes nodes = clusterState .nodes ();
1150- final boolean isStreamingCandidate = (searchRequest .getStreamingSearchMode () != null )
1151- && searchRequest .scroll () == null ;
1152- final boolean streamingEnabledSetting = clusterService .getClusterSettings ().get (StreamSearchTransportService .STREAM_SEARCH_ENABLED );
1153- final boolean streamingEnabledEffective = streamingEnabledSetting || FeatureFlags .isEnabled (FeatureFlags .STREAM_TRANSPORT );
1154- final boolean useStreamingTransportForConnection = isStreamingCandidate
1155- && streamSearchTransportService != null
1156- && streamingEnabledEffective ;
1157- final SearchTransportService connectionTransport = useStreamingTransportForConnection
1158- ? streamSearchTransportService
1159- : searchTransportService ;
11601144 BiFunction <String , String , Transport .Connection > connectionLookup = buildConnectionLookup (
11611145 searchRequest .getLocalClusterAlias (),
11621146 nodes ::get ,
11631147 remoteConnections ,
1164- connectionTransport ::getConnection
1148+ searchTransportService ::getConnection
11651149 );
11661150 final Executor asyncSearchExecutor = asyncSearchExecutor (concreteLocalIndices , clusterState );
11671151 final boolean preFilterSearchShards = shouldPreFilterSearchShards (
@@ -1290,31 +1274,10 @@ AbstractSearchAsyncAction<? extends SearchPhaseResult> searchAsyncAction(
12901274 SearchResponse .Clusters clusters ,
12911275 SearchRequestContext searchRequestContext
12921276 ) {
1293- // Determine if this request should use streaming transport
1294- final boolean isStreamingCandidate = (searchRequest .getStreamingSearchMode () != null )
1295- && searchRequest .scroll () == null ;
1296-
1297- // Check if streaming transport is actually available and enabled (cluster setting OR feature flag)
1298- final boolean streamingEnabledSetting = clusterService .getClusterSettings ().get (StreamSearchTransportService .STREAM_SEARCH_ENABLED );
1299- final boolean streamingEnabledEffective = streamingEnabledSetting || FeatureFlags .isEnabled (FeatureFlags .STREAM_TRANSPORT );
1300- final boolean canUseStreamingTransport = (streamSearchTransportService != null ) && streamingEnabledEffective ;
1301-
1302- // Use streaming transport for streaming search requests
1303- final boolean useStreamingTransport = isStreamingCandidate && canUseStreamingTransport ;
1304-
13051277 if (preFilter ) {
1306- if (logger .isTraceEnabled ()) {
1307- logger .trace (
1308- "prefilter using transport [{}] (streaming={}, enabled={}, canUse={})" ,
1309- ((isStreamingCandidate && canUseStreamingTransport ) ? "stream" : "classic" ),
1310- isStreamingCandidate ,
1311- streamingEnabledSetting ,
1312- canUseStreamingTransport
1313- );
1314- }
13151278 return new CanMatchPreFilterSearchPhase (
13161279 logger ,
1317- ( isStreamingCandidate && useStreamingTransport ) ? streamSearchTransportService : searchTransportService ,
1280+ searchTransportService ,
13181281 connectionLookup ,
13191282 aliasFilter ,
13201283 concreteIndexBoosts ,
@@ -1350,34 +1313,21 @@ AbstractSearchAsyncAction<? extends SearchPhaseResult> searchAsyncAction(
13501313 tracer
13511314 );
13521315 } else {
1353- final boolean isStreamingRequest = (searchRequest .getStreamingSearchMode () != null );
1354-
1355- final SearchProgressListener progressListener = task .getProgressListener ();
1356-
13571316 final QueryPhaseResultConsumer queryResultConsumer = searchPhaseController .newSearchPhaseResults (
13581317 executor ,
13591318 circuitBreaker ,
1360- progressListener ,
1319+ task . getProgressListener () ,
13611320 searchRequest ,
13621321 shardIterators .size (),
13631322 exc -> cancelTask (task , exc ),
13641323 task ::isCancelled
13651324 );
1366- if (logger .isTraceEnabled ()) {
1367- logger .trace (
1368- "query phase using transport [{}] (streamingRequest={}, enabled={}, canUse={})" ,
1369- ((isStreamingRequest && useStreamingTransport ) ? "stream" : "classic" ),
1370- isStreamingRequest ,
1371- streamingEnabledSetting ,
1372- canUseStreamingTransport
1373- );
1374- }
13751325 AbstractSearchAsyncAction <? extends SearchPhaseResult > searchAsyncAction ;
13761326 switch (searchRequest .searchType ()) {
13771327 case DFS_QUERY_THEN_FETCH :
13781328 searchAsyncAction = new SearchDfsQueryThenFetchAsyncAction (
13791329 logger ,
1380- ( isStreamingRequest && canUseStreamingTransport ) ? streamSearchTransportService : searchTransportService ,
1330+ searchTransportService ,
13811331 connectionLookup ,
13821332 aliasFilter ,
13831333 concreteIndexBoosts ,
@@ -1397,49 +1347,26 @@ AbstractSearchAsyncAction<? extends SearchPhaseResult> searchAsyncAction(
13971347 );
13981348 break ;
13991349 case QUERY_THEN_FETCH :
1400- if (isStreamingRequest && canUseStreamingTransport ) {
1401- searchAsyncAction = new StreamSearchQueryThenFetchAsyncAction (
1402- logger ,
1403- streamSearchTransportService ,
1404- connectionLookup ,
1405- aliasFilter ,
1406- concreteIndexBoosts ,
1407- indexRoutings ,
1408- searchPhaseController ,
1409- executor ,
1410- queryResultConsumer ,
1411- searchRequest ,
1412- listener ,
1413- shardIterators ,
1414- timeProvider ,
1415- clusterState ,
1416- task ,
1417- clusters ,
1418- searchRequestContext ,
1419- tracer
1420- );
1421- } else {
1422- searchAsyncAction = new SearchQueryThenFetchAsyncAction (
1423- logger ,
1424- searchTransportService ,
1425- connectionLookup ,
1426- aliasFilter ,
1427- concreteIndexBoosts ,
1428- indexRoutings ,
1429- searchPhaseController ,
1430- executor ,
1431- queryResultConsumer ,
1432- searchRequest ,
1433- listener ,
1434- shardIterators ,
1435- timeProvider ,
1436- clusterState ,
1437- task ,
1438- clusters ,
1439- searchRequestContext ,
1440- tracer
1441- );
1442- }
1350+ searchAsyncAction = new SearchQueryThenFetchAsyncAction (
1351+ logger ,
1352+ searchTransportService ,
1353+ connectionLookup ,
1354+ aliasFilter ,
1355+ concreteIndexBoosts ,
1356+ indexRoutings ,
1357+ searchPhaseController ,
1358+ executor ,
1359+ queryResultConsumer ,
1360+ searchRequest ,
1361+ listener ,
1362+ shardIterators ,
1363+ timeProvider ,
1364+ clusterState ,
1365+ task ,
1366+ clusters ,
1367+ searchRequestContext ,
1368+ tracer
1369+ );
14431370 break ;
14441371 default :
14451372 throw new IllegalStateException ("Unknown search type: [" + searchRequest .searchType () + "]" );
0 commit comments