本文整理了Java中org.elasticsearch.search.builder.SearchSourceBuilder.trackTotalHits()
方法的一些代码示例,展示了SearchSourceBuilder.trackTotalHits()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchSourceBuilder.trackTotalHits()
方法的具体详情如下:
包路径:org.elasticsearch.search.builder.SearchSourceBuilder
类名称:SearchSourceBuilder
方法名:trackTotalHits
[英]Indicates if the total hit count for the query should be tracked.
[中]指示是否应跟踪查询的总命中率。
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* 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;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* 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);
}
};
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@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;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* 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;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* 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;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
searchSourceBuilder.trackTotalHits(request.paramAsBoolean("track_total_hits", true));
代码示例来源:origin: org.elasticsearch/elasticsearch
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());
代码示例来源:origin: apache/servicemix-bundles
@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;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* 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);
}
};
}
代码示例来源:origin: apache/servicemix-bundles
/**
* 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);
}
};
}
代码示例来源:origin: DigitalPebble/storm-crawler
sourceBuilder.size(maxBucketNum);
sourceBuilder.explain(false);
sourceBuilder.trackTotalHits(false);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@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;
}
代码示例来源:origin: DigitalPebble/storm-crawler
sourceBuilder.size(0);
sourceBuilder.explain(false);
sourceBuilder.trackTotalHits(false);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
searchSourceBuilder.trackTotalHits(request.paramAsBoolean("track_total_hits", true));
代码示例来源:origin: apache/servicemix-bundles
searchSourceBuilder.trackTotalHits(request.paramAsBoolean("track_total_hits", true));
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
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());
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
builder.trackTotalHits(randomBoolean());
内容来源于网络,如有侵权,请联系作者删除!