diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java index 1c42fb40a0e..75c40ac1495 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.search; import org.elasticsearch.ElasticSearchIllegalArgumentException; +import org.elasticsearch.common.Nullable; /** * Controls the operation threading model for search operation that are performed @@ -65,7 +66,7 @@ public enum SearchOperationThreading { throw new ElasticSearchIllegalArgumentException("No type matching id [" + id + "]"); } - public static SearchOperationThreading fromString(String value, SearchOperationThreading defaultValue) { + public static SearchOperationThreading fromString(String value, @Nullable SearchOperationThreading defaultValue) { if (value == null) { return defaultValue; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 9a880b67a9f..f46cef0d81d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -69,12 +69,14 @@ public class RestSearchAction extends BaseRestHandler { try { searchRequest = parseSearchRequest(request); searchRequest.listenerThreaded(false); - SearchOperationThreading operationThreading = SearchOperationThreading.fromString(request.param("operation_threading"), SearchOperationThreading.SINGLE_THREAD); - if (operationThreading == SearchOperationThreading.NO_THREADS) { - // since we don't spawn, don't allow no_threads, but change it to a single thread - operationThreading = SearchOperationThreading.SINGLE_THREAD; + SearchOperationThreading operationThreading = SearchOperationThreading.fromString(request.param("operation_threading"), null); + if (operationThreading != null) { + if (operationThreading == SearchOperationThreading.NO_THREADS) { + // since we don't spawn, don't allow no_threads, but change it to a single thread + operationThreading = SearchOperationThreading.SINGLE_THREAD; + } + searchRequest.operationThreading(operationThreading); } - searchRequest.operationThreading(operationThreading); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("failed to parse search request parameters", e); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java index ef833b60e54..cead1a36827 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java @@ -68,12 +68,14 @@ public class RestSearchScrollAction extends BaseRestHandler { searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null))); } searchScrollRequest.listenerThreaded(false); - SearchOperationThreading operationThreading = SearchOperationThreading.fromString(request.param("operation_threading"), SearchOperationThreading.SINGLE_THREAD); - if (operationThreading == SearchOperationThreading.NO_THREADS) { - // since we don't spawn, don't allow no_threads, but change it to a single thread - operationThreading = SearchOperationThreading.SINGLE_THREAD; + SearchOperationThreading operationThreading = SearchOperationThreading.fromString(request.param("operation_threading"), null); + if (operationThreading != null) { + if (operationThreading == SearchOperationThreading.NO_THREADS) { + // since we don't spawn, don't allow no_threads, but change it to a single thread + operationThreading = SearchOperationThreading.SINGLE_THREAD; + } + searchScrollRequest.operationThreading(operationThreading); } - searchScrollRequest.operationThreading(operationThreading); } catch (Exception e) { try { XContentBuilder builder = restContentBuilder(request);