Cleanup BWC for single shard optimization

The BWC layer is needed only for pre 5.3 indices.
This commit is contained in:
Jim Ferenczi 2017-05-09 16:54:44 +02:00
parent a72eaa8e0f
commit a404f0aca7
2 changed files with 11 additions and 5 deletions

View File

@ -120,14 +120,15 @@ public class SearchTransportService extends AbstractComponent {
// this used to be the QUERY_AND_FETCH which doesn't exists anymore. // this used to be the QUERY_AND_FETCH which doesn't exists 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().onOrBefore(Version.V_5_3_0_UNRELEASED) && fetchDocuments) { if (connection.getVersion().before(Version.V_5_3_0_UNRELEASED) && fetchDocuments) {
if (connection.getVersion().before(Version.V_5_3_0_UNRELEASED) && request.scroll() != null) { // 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. * 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 * 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}. * 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 // TODO this BWC layer can be removed once this is back-ported to 5.3
transportService.sendChildRequest(connection, QUERY_FETCH_ACTION_NAME, request, task, transportService.sendChildRequest(connection, QUERY_FETCH_ACTION_NAME, request, task,

View File

@ -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 * 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). * 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 // 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}. * The default search type ({@link #QUERY_THEN_FETCH}.