From fcc60609ae79f14ef4a9e9c0a64880fc52685110 Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 6 Oct 2015 15:55:18 +0200 Subject: [PATCH] Count api: simplify default handling For minScore and terminateAfter we can just rely on defaults set to SearchSourceBuilder. --- .../java/org/elasticsearch/action/count/CountRequest.java | 6 ------ .../elasticsearch/rest/action/count/RestCountAction.java | 6 ++++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/count/CountRequest.java b/core/src/main/java/org/elasticsearch/action/count/CountRequest.java index 9fa73f6bfdc..aa22b8add14 100644 --- a/core/src/main/java/org/elasticsearch/action/count/CountRequest.java +++ b/core/src/main/java/org/elasticsearch/action/count/CountRequest.java @@ -31,8 +31,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder; import java.io.IOException; import java.util.Arrays; -import static org.elasticsearch.search.internal.SearchContext.DEFAULT_TERMINATE_AFTER; - /** * A request to count the number of documents matching a specific query. Best created with * {@link org.elasticsearch.client.Requests#countRequest(String...)}. @@ -43,8 +41,6 @@ import static org.elasticsearch.search.internal.SearchContext.DEFAULT_TERMINATE_ */ public class CountRequest extends BroadcastRequest { - public static final float DEFAULT_MIN_SCORE = -1f; - @Nullable protected String routing; @@ -62,8 +58,6 @@ public class CountRequest extends BroadcastRequest { public CountRequest(String... indices) { super(indices); searchSourceBuilder.size(0); - searchSourceBuilder.minScore(DEFAULT_MIN_SCORE); - searchSourceBuilder.terminateAfter(DEFAULT_TERMINATE_AFTER); } /** diff --git a/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java b/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java index c87fa609f3d..56eeafc9089 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java @@ -45,7 +45,6 @@ import org.elasticsearch.rest.action.support.RestBuilderListener; import java.io.IOException; -import static org.elasticsearch.action.count.CountRequest.DEFAULT_MIN_SCORE; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; @@ -91,7 +90,10 @@ public class RestCountAction extends BaseRestHandler { } } countRequest.routing(request.param("routing")); - countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE)); + float minScore = request.paramAsFloat("min_score", -1f); + if (minScore != -1f) { + countRequest.minScore(minScore); + } countRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); countRequest.preference(request.param("preference"));