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
This commit is contained in:
parent
52719b2118
commit
4a30e23365
|
@ -71,7 +71,6 @@ public class SearchTransportService extends AbstractComponent {
|
||||||
public static final String QUERY_ACTION_NAME = "indices:data/read/search[phase/query]";
|
public static final String QUERY_ACTION_NAME = "indices:data/read/search[phase/query]";
|
||||||
public static final String QUERY_ID_ACTION_NAME = "indices:data/read/search[phase/query/id]";
|
public static final String QUERY_ID_ACTION_NAME = "indices:data/read/search[phase/query/id]";
|
||||||
public static final String QUERY_SCROLL_ACTION_NAME = "indices:data/read/search[phase/query/scroll]";
|
public static final String QUERY_SCROLL_ACTION_NAME = "indices:data/read/search[phase/query/scroll]";
|
||||||
public static final String QUERY_FETCH_ACTION_NAME = "indices:data/read/search[phase/query+fetch]";
|
|
||||||
public static final String QUERY_FETCH_SCROLL_ACTION_NAME = "indices:data/read/search[phase/query+fetch/scroll]";
|
public static final String QUERY_FETCH_SCROLL_ACTION_NAME = "indices:data/read/search[phase/query+fetch/scroll]";
|
||||||
public static final String FETCH_ID_SCROLL_ACTION_NAME = "indices:data/read/search[phase/fetch/id/scroll]";
|
public static final String FETCH_ID_SCROLL_ACTION_NAME = "indices:data/read/search[phase/fetch/id/scroll]";
|
||||||
public static final String FETCH_ID_ACTION_NAME = "indices:data/read/search[phase/fetch/id]";
|
public static final String FETCH_ID_ACTION_NAME = "indices:data/read/search[phase/fetch/id]";
|
||||||
|
@ -117,27 +116,12 @@ public class SearchTransportService extends AbstractComponent {
|
||||||
public void sendExecuteQuery(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task,
|
public void sendExecuteQuery(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task,
|
||||||
final SearchActionListener<SearchPhaseResult> listener) {
|
final SearchActionListener<SearchPhaseResult> listener) {
|
||||||
// we optimize this and expect a QueryFetchSearchResult if we only have a single shard in the search request
|
// we optimize this and expect a QueryFetchSearchResult if we only have a single shard in the search request
|
||||||
// this used to be the QUERY_AND_FETCH which doesn't exists anymore.
|
// this used to be the QUERY_AND_FETCH which doesn't exist anymore.
|
||||||
final boolean fetchDocuments = request.numberOfShards() == 1;
|
final boolean fetchDocuments = request.numberOfShards() == 1;
|
||||||
Supplier<SearchPhaseResult> supplier = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new;
|
Supplier<SearchPhaseResult> supplier = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new;
|
||||||
if (connection.getVersion().before(Version.V_5_3_0) && fetchDocuments) {
|
|
||||||
// this is a BWC layer for pre 5.3 indices
|
|
||||||
if (request.scroll() != null) {
|
|
||||||
/**
|
|
||||||
* This is needed for nodes pre 5.3 when the single shard optimization is used.
|
|
||||||
* These nodes will set the last emitted doc only if the removed `query_and_fetch` search type is set
|
|
||||||
* in the request. See {@link SearchType}.
|
|
||||||
*/
|
|
||||||
request.searchType(SearchType.QUERY_AND_FETCH);
|
|
||||||
}
|
|
||||||
// TODO this BWC layer can be removed once this is back-ported to 5.3
|
|
||||||
transportService.sendChildRequest(connection, QUERY_FETCH_ACTION_NAME, request, task,
|
|
||||||
new ActionListenerResponseHandler<>(listener, supplier));
|
|
||||||
} else {
|
|
||||||
transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task,
|
transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task,
|
||||||
new ActionListenerResponseHandler<>(listener, supplier));
|
new ActionListenerResponseHandler<>(listener, supplier));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void sendExecuteQuery(Transport.Connection connection, final QuerySearchRequest request, SearchTask task,
|
public void sendExecuteQuery(Transport.Connection connection, final QuerySearchRequest request, SearchTask task,
|
||||||
final SearchActionListener<QuerySearchResult> listener) {
|
final SearchActionListener<QuerySearchResult> listener) {
|
||||||
|
@ -353,20 +337,6 @@ public class SearchTransportService extends AbstractComponent {
|
||||||
});
|
});
|
||||||
TransportActionProxy.registerProxyAction(transportService, QUERY_SCROLL_ACTION_NAME, ScrollQuerySearchResult::new);
|
TransportActionProxy.registerProxyAction(transportService, QUERY_SCROLL_ACTION_NAME, ScrollQuerySearchResult::new);
|
||||||
|
|
||||||
// this is for BWC with 5.3 until the QUERY_AND_FETCH removal change has been back-ported to 5.x
|
|
||||||
// in 5.3 we will only execute a `indices:data/read/search[phase/query+fetch]` if the node is pre 5.3
|
|
||||||
// such that we can remove this after the back-port.
|
|
||||||
transportService.registerRequestHandler(QUERY_FETCH_ACTION_NAME, ShardSearchTransportRequest::new, ThreadPool.Names.SEARCH,
|
|
||||||
new TaskAwareTransportRequestHandler<ShardSearchTransportRequest>() {
|
|
||||||
@Override
|
|
||||||
public void messageReceived(ShardSearchTransportRequest request, TransportChannel channel, Task task) throws Exception {
|
|
||||||
assert request.numberOfShards() == 1 : "expected single shard request but got: " + request.numberOfShards();
|
|
||||||
SearchPhaseResult result = searchService.executeQueryPhase(request, (SearchTask)task);
|
|
||||||
channel.sendResponse(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
TransportActionProxy.registerProxyAction(transportService, QUERY_FETCH_ACTION_NAME, QueryFetchSearchResult::new);
|
|
||||||
|
|
||||||
transportService.registerRequestHandler(QUERY_FETCH_SCROLL_ACTION_NAME, InternalScrollSearchRequest::new, ThreadPool.Names.SEARCH,
|
transportService.registerRequestHandler(QUERY_FETCH_SCROLL_ACTION_NAME, InternalScrollSearchRequest::new, ThreadPool.Names.SEARCH,
|
||||||
new TaskAwareTransportRequestHandler<InternalScrollSearchRequest>() {
|
new TaskAwareTransportRequestHandler<InternalScrollSearchRequest>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue