Search API: REST endpoint should use default operation_threading of thread_per_shard, closes #1154.

This commit is contained in:
Shay Banon 2011-07-24 20:51:49 +03:00
parent 5ce42b337d
commit 31ea01bbc6
3 changed files with 16 additions and 11 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);