From 31ea01bbc68f64cd7787b97479cb5deba1b529b9 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 24 Jul 2011 20:51:49 +0300 Subject: [PATCH] Search API: REST endpoint should use default operation_threading of thread_per_shard, closes #1154. --- .../action/search/SearchOperationThreading.java | 3 ++- .../rest/action/search/RestSearchAction.java | 12 +++++++----- .../rest/action/search/RestSearchScrollAction.java | 12 +++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) 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);