/** * Indicates if the total hit count for the query should be tracked. Defaults to {@code true} */ public SearchRequestBuilder setTrackTotalHits(boolean trackTotalHits) { sourceBuilder().trackTotalHits(trackTotalHits); return this; }
/** * Returns a new ArraySearchPhaseResults instance. This might return an instance that reduces search responses incrementally. */ InitialSearchPhase.ArraySearchPhaseResults<SearchPhaseResult> newSearchPhaseResults(SearchRequest request, int numShards) { SearchSourceBuilder source = request.source(); boolean isScrollRequest = request.scroll() != null; final boolean hasAggs = source != null && source.aggregations() != null; final boolean hasTopDocs = source == null || source.size() != 0; final boolean trackTotalHits = source == null || source.trackTotalHits(); if (isScrollRequest == false && (hasAggs || hasTopDocs)) { // no incremental reduce if scroll is used - we only hit a single shard or sometimes more... if (request.getBatchedReduceSize() < numShards) { // only use this if there are aggs and if there are more shards than we should reduce at once return new QueryPhaseResultConsumer(this, numShards, request.getBatchedReduceSize(), hasTopDocs, hasAggs); } } return new InitialSearchPhase.ArraySearchPhaseResults<SearchPhaseResult>(numShards) { @Override ReducedQueryPhase reduce() { return reducedQueryPhase(results.asList(), isScrollRequest, trackTotalHits); } }; }
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; final Scroll scroll = scroll(); if (source != null && source.trackTotalHits() == false && scroll != null) { validationException = addValidationError("disabling [track_total_hits] is not allowed in a scroll context", validationException); } if (source != null && source.from() > 0 && scroll != null) { validationException = addValidationError("using [from] is not allowed in a scroll context", validationException); } if (requestCache != null && requestCache && scroll != null) { DEPRECATION_LOGGER.deprecated("Explicitly set [request_cache] for a scroll query is deprecated and will return a 400 " + "error in future versions"); } if (source != null && source.size() == 0 && scroll != null) { validationException = addValidationError("[size] cannot be [0] in a scroll context", validationException); } if (source != null && source.rescores() != null && source.rescores().isEmpty() == false && scroll != null) { DEPRECATION_LOGGER.deprecated("Using [rescore] for a scroll query is deprecated and will be ignored. From 7.0 on will " + "return a 400 error"); } return validationException; }
/** * Indicates if the total hit count for the query should be tracked. Defaults to {@code true} */ public SearchRequestBuilder setTrackTotalHits(boolean trackTotalHits) { sourceBuilder().trackTotalHits(trackTotalHits); return this; }
/** * Indicates if the total hit count for the query should be tracked. Defaults to {@code true} */ public SearchRequestBuilder setTrackTotalHits(boolean trackTotalHits) { sourceBuilder().trackTotalHits(trackTotalHits); return this; }
searchSourceBuilder.trackTotalHits(request.paramAsBoolean("track_total_hits", true));
if (source.trackTotalHits() == false && context.scrollContext() != null) { throw new SearchContextException(context, "disabling [track_total_hits] is not allowed in a scroll context"); context.trackTotalHits(source.trackTotalHits()); if (source.minScore() != null) { context.minimumScore(source.minScore());
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; final Scroll scroll = scroll(); if (source != null && source.trackTotalHits() == false && scroll != null) { validationException = addValidationError("disabling [track_total_hits] is not allowed in a scroll context", validationException); } if (source != null && source.from() > 0 && scroll != null) { validationException = addValidationError("using [from] is not allowed in a scroll context", validationException); } if (requestCache != null && requestCache && scroll != null) { DEPRECATION_LOGGER.deprecated("Explicitly set [request_cache] for a scroll query is deprecated and will return a 400 " + "error in future versions"); } if (source != null && source.size() == 0 && scroll != null) { validationException = addValidationError("[size] cannot be [0] in a scroll context", validationException); } return validationException; }
/** * Returns a new ArraySearchPhaseResults instance. This might return an instance that reduces search responses incrementally. */ InitialSearchPhase.ArraySearchPhaseResults<SearchPhaseResult> newSearchPhaseResults(SearchRequest request, int numShards) { SearchSourceBuilder source = request.source(); boolean isScrollRequest = request.scroll() != null; final boolean hasAggs = source != null && source.aggregations() != null; final boolean hasTopDocs = source == null || source.size() != 0; final boolean trackTotalHits = source == null || source.trackTotalHits(); if (isScrollRequest == false && (hasAggs || hasTopDocs)) { // no incremental reduce if scroll is used - we only hit a single shard or sometimes more... if (request.getBatchedReduceSize() < numShards) { // only use this if there are aggs and if there are more shards than we should reduce at once return new QueryPhaseResultConsumer(this, numShards, request.getBatchedReduceSize(), hasTopDocs, hasAggs); } } return new InitialSearchPhase.ArraySearchPhaseResults(numShards) { @Override public ReducedQueryPhase reduce() { return reducedQueryPhase(results.asList(), isScrollRequest, trackTotalHits); } }; }
/** * Returns a new ArraySearchPhaseResults instance. This might return an instance that reduces search responses incrementally. */ InitialSearchPhase.ArraySearchPhaseResults<SearchPhaseResult> newSearchPhaseResults(SearchRequest request, int numShards) { SearchSourceBuilder source = request.source(); boolean isScrollRequest = request.scroll() != null; final boolean hasAggs = source != null && source.aggregations() != null; final boolean hasTopDocs = source == null || source.size() != 0; final boolean trackTotalHits = source == null || source.trackTotalHits(); if (isScrollRequest == false && (hasAggs || hasTopDocs)) { // no incremental reduce if scroll is used - we only hit a single shard or sometimes more... if (request.getBatchedReduceSize() < numShards) { // only use this if there are aggs and if there are more shards than we should reduce at once return new QueryPhaseResultConsumer(this, numShards, request.getBatchedReduceSize(), hasTopDocs, hasAggs); } } return new InitialSearchPhase.ArraySearchPhaseResults(numShards) { @Override public ReducedQueryPhase reduce() { return reducedQueryPhase(results.asList(), isScrollRequest, trackTotalHits); } }; }
sourceBuilder.size(maxBucketNum); sourceBuilder.explain(false); sourceBuilder.trackTotalHits(false);
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; final Scroll scroll = scroll(); if (source != null && source.trackTotalHits() == false && scroll != null) { validationException = addValidationError("disabling [track_total_hits] is not allowed in a scroll context", validationException); } if (source != null && source.from() > 0 && scroll != null) { validationException = addValidationError("using [from] is not allowed in a scroll context", validationException); } if (requestCache != null && requestCache && scroll != null) { DEPRECATION_LOGGER.deprecated("Explicitly set [request_cache] for a scroll query is deprecated and will return a 400 " + "error in future versions"); } if (source != null && source.size() == 0 && scroll != null) { validationException = addValidationError("[size] cannot be [0] in a scroll context", validationException); } if (source != null && source.rescores() != null && source.rescores().isEmpty() == false && scroll != null) { DEPRECATION_LOGGER.deprecated("Using [rescore] for a scroll query is deprecated and will be ignored. From 7.0 on will " + "return a 400 error"); } return validationException; }
sourceBuilder.size(0); sourceBuilder.explain(false); sourceBuilder.trackTotalHits(false);
searchSourceBuilder.trackTotalHits(request.paramAsBoolean("track_total_hits", true));
searchSourceBuilder.trackTotalHits(request.paramAsBoolean("track_total_hits", true));
if (source.trackTotalHits() == false && context.scrollContext() != null) { throw new SearchContextException(context, "disabling [track_total_hits] is not allowed in a scroll context"); context.trackTotalHits(source.trackTotalHits()); if (source.minScore() != null) { context.minimumScore(source.minScore());
builder.trackTotalHits(randomBoolean());