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 3699d3d0139..2ecfc213f97 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -120,14 +120,15 @@ public class SearchTransportService extends AbstractComponent { // this used to be the QUERY_AND_FETCH which doesn't exists anymore. final boolean fetchDocuments = request.numberOfShards() == 1; Supplier supplier = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new; - if (connection.getVersion().onOrBefore(Version.V_5_3_0_UNRELEASED) && fetchDocuments) { - if (connection.getVersion().before(Version.V_5_3_0_UNRELEASED) && request.scroll() != null) { + if (connection.getVersion().before(Version.V_5_3_0_UNRELEASED) && 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.fromId((byte) 3)); + 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, diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchType.java b/core/src/main/java/org/elasticsearch/action/search/SearchType.java index 7dd4aebc5e0..b8001204087 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchType.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchType.java @@ -36,9 +36,14 @@ public enum SearchType { * document content. The return number of hits is exactly as specified in size, since they are the only ones that * are fetched. This is very handy when the index has a lot of shards (not replicas, shard id groups). */ - QUERY_THEN_FETCH((byte) 1); + QUERY_THEN_FETCH((byte) 1), // 2 used to be DFS_QUERY_AND_FETCH - // 3 used to be QUERY_AND_FETCH + + /** + * Only used for pre 5.3 request where this type is still needed + */ + @Deprecated + QUERY_AND_FETCH((byte) 3); /** * The default search type ({@link #QUERY_THEN_FETCH}.