From ed871b0853a4c745aa4f1e77a5fa4c355ab0503a Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 14 Jun 2017 09:18:21 -0600 Subject: [PATCH 1/3] 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. --- .../action/search/SearchTransportService.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java index 5ed41d0fe656b..75b1ebbd7558d 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -117,26 +117,11 @@ public void sendExecuteDfs(Transport.Connection connection, final ShardSearchTra public void sendExecuteQuery(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task, final SearchActionListener listener) { // 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; Supplier 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, new ActionListenerResponseHandler<>(listener, supplier)); - } } public void sendExecuteQuery(Transport.Connection connection, final QuerySearchRequest request, SearchTask task, From b032366ef5a4da1687b001e647d44b4e147b417a Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 14 Jun 2017 09:49:26 -0600 Subject: [PATCH 2/3] Fix indentation --- .../elasticsearch/action/search/SearchTransportService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java index 75b1ebbd7558d..a84bae1ad4afe 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -120,8 +120,8 @@ public void sendExecuteQuery(Transport.Connection connection, final ShardSearchT // this used to be the QUERY_AND_FETCH which doesn't exist anymore. final boolean fetchDocuments = request.numberOfShards() == 1; Supplier supplier = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new; - transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task, - new ActionListenerResponseHandler<>(listener, supplier)); + transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task, + new ActionListenerResponseHandler<>(listener, supplier)); } public void sendExecuteQuery(Transport.Connection connection, final QuerySearchRequest request, SearchTask task, From 1c41050e924cf5b07c589689e55e759c52ce1c55 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 14 Jun 2017 09:49:48 -0600 Subject: [PATCH 3/3] Remove unused QUERY_FETCH_ACTION_NAME constant --- .../action/search/SearchTransportService.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java index a84bae1ad4afe..e75d52db3ef31 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -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_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_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 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]"; @@ -338,20 +337,6 @@ public void messageReceived(InternalScrollSearchRequest request, TransportChanne }); 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() { - @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, new TaskAwareTransportRequestHandler() { @Override