Skip to content

Commit 4a30e23

Browse files
authored
Remove QUERY_AND_FETCH BWC for pre-5.3.0 nodes (#25223)
* Remove QUERY_AND_FETCH BWC for pre-5.3.0 nodes This was a BWC layer where we expicitly set the `search_type` to "query_and_fetch" when a single node is queried on pre-5.3 nodes. Since 6.0 no longer needs to be compatible with 5.3 nodes, this can be removed. * Fix indentation * Remove unused QUERY_FETCH_ACTION_NAME constant
1 parent 52719b2 commit 4a30e23

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public class SearchTransportService extends AbstractComponent {
7171
public static final String QUERY_ACTION_NAME = "indices:data/read/search[phase/query]";
7272
public static final String QUERY_ID_ACTION_NAME = "indices:data/read/search[phase/query/id]";
7373
public static final String QUERY_SCROLL_ACTION_NAME = "indices:data/read/search[phase/query/scroll]";
74-
public static final String QUERY_FETCH_ACTION_NAME = "indices:data/read/search[phase/query+fetch]";
7574
public static final String QUERY_FETCH_SCROLL_ACTION_NAME = "indices:data/read/search[phase/query+fetch/scroll]";
7675
public static final String FETCH_ID_SCROLL_ACTION_NAME = "indices:data/read/search[phase/fetch/id/scroll]";
7776
public static final String FETCH_ID_ACTION_NAME = "indices:data/read/search[phase/fetch/id]";
@@ -117,26 +116,11 @@ public void sendExecuteDfs(Transport.Connection connection, final ShardSearchTra
117116
public void sendExecuteQuery(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task,
118117
final SearchActionListener<SearchPhaseResult> listener) {
119118
// we optimize this and expect a QueryFetchSearchResult if we only have a single shard in the search request
120-
// this used to be the QUERY_AND_FETCH which doesn't exists anymore.
119+
// this used to be the QUERY_AND_FETCH which doesn't exist anymore.
121120
final boolean fetchDocuments = request.numberOfShards() == 1;
122121
Supplier<SearchPhaseResult> supplier = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new;
123-
if (connection.getVersion().before(Version.V_5_3_0) && fetchDocuments) {
124-
// this is a BWC layer for pre 5.3 indices
125-
if (request.scroll() != null) {
126-
/**
127-
* This is needed for nodes pre 5.3 when the single shard optimization is used.
128-
* These nodes will set the last emitted doc only if the removed `query_and_fetch` search type is set
129-
* in the request. See {@link SearchType}.
130-
*/
131-
request.searchType(SearchType.QUERY_AND_FETCH);
132-
}
133-
// TODO this BWC layer can be removed once this is back-ported to 5.3
134-
transportService.sendChildRequest(connection, QUERY_FETCH_ACTION_NAME, request, task,
135-
new ActionListenerResponseHandler<>(listener, supplier));
136-
} else {
137-
transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task,
138-
new ActionListenerResponseHandler<>(listener, supplier));
139-
}
122+
transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task,
123+
new ActionListenerResponseHandler<>(listener, supplier));
140124
}
141125

142126
public void sendExecuteQuery(Transport.Connection connection, final QuerySearchRequest request, SearchTask task,
@@ -353,20 +337,6 @@ public void messageReceived(InternalScrollSearchRequest request, TransportChanne
353337
});
354338
TransportActionProxy.registerProxyAction(transportService, QUERY_SCROLL_ACTION_NAME, ScrollQuerySearchResult::new);
355339

356-
// this is for BWC with 5.3 until the QUERY_AND_FETCH removal change has been back-ported to 5.x
357-
// in 5.3 we will only execute a `indices:data/read/search[phase/query+fetch]` if the node is pre 5.3
358-
// such that we can remove this after the back-port.
359-
transportService.registerRequestHandler(QUERY_FETCH_ACTION_NAME, ShardSearchTransportRequest::new, ThreadPool.Names.SEARCH,
360-
new TaskAwareTransportRequestHandler<ShardSearchTransportRequest>() {
361-
@Override
362-
public void messageReceived(ShardSearchTransportRequest request, TransportChannel channel, Task task) throws Exception {
363-
assert request.numberOfShards() == 1 : "expected single shard request but got: " + request.numberOfShards();
364-
SearchPhaseResult result = searchService.executeQueryPhase(request, (SearchTask)task);
365-
channel.sendResponse(result);
366-
}
367-
});
368-
TransportActionProxy.registerProxyAction(transportService, QUERY_FETCH_ACTION_NAME, QueryFetchSearchResult::new);
369-
370340
transportService.registerRequestHandler(QUERY_FETCH_SCROLL_ACTION_NAME, InternalScrollSearchRequest::new, ThreadPool.Names.SEARCH,
371341
new TaskAwareTransportRequestHandler<InternalScrollSearchRequest>() {
372342
@Override

0 commit comments

Comments
 (0)