本文整理了Java中org.elasticsearch.search.builder.SearchSourceBuilder.size()
方法的一些代码示例,展示了SearchSourceBuilder.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchSourceBuilder.size()
方法的具体详情如下:
包路径:org.elasticsearch.search.builder.SearchSourceBuilder
类名称:SearchSourceBuilder
方法名:size
[英]Gets the number of search hits to return.
[中]获取要返回的搜索命中数。
代码示例来源:origin: Graylog2/graylog2-server
.size(350)
.sort(SortBuilders.fieldSort(FieldSortBuilder.DOC_FIELD_NAME))
.toString();
代码示例来源:origin: Netflix/conductor
searchSourceBuilder.query(queryBuilder);
searchSourceBuilder.from(start);
searchSourceBuilder.size(size);
代码示例来源:origin: Graylog2/graylog2-server
final String query = searchSource()
.aggregation(builder)
.size(0)
.toString();
代码示例来源:origin: floragunncom/search-guard
&& sr.source().aggregations().getAggregatorFactories() != null
&& sr.source().aggregations().getAggregatorFactories().size() == 1
&& sr.source().size() == 0) {
AggregationBuilder ab = sr.source().aggregations().getAggregatorFactories().iterator().next();
if( ab instanceof TermsAggregationBuilder
代码示例来源:origin: Graylog2/graylog2-server
searchSourceBuilder.size(limit);
代码示例来源:origin: Graylog2/graylog2-server
private long totalCount(final String[] indexNames) {
// Return 0 if there are no indices in the given index set. If we run the query with an empty index list,
// Elasticsearch will count all documents in all indices and thus return a wrong count.
if (indexNames.length == 0) {
return 0L;
}
final List<String> indices = Arrays.asList(indexNames);
final String query = new SearchSourceBuilder()
.query(QueryBuilders.matchAllQuery())
.size(0)
.toString();
final Search request = new Search.Builder(query)
.addIndex(indices)
.build();
final MultiSearch multiSearch = new MultiSearch.Builder(request).build();
final MultiSearchResult searchResult = JestUtils.execute(jestClient, multiSearch, () -> "Fetching message count failed for indices " + indices);
final List<MultiSearchResult.MultiSearchResponse> responses = searchResult.getResponses();
long total = 0L;
for (MultiSearchResult.MultiSearchResponse response : responses) {
if (response.isError) {
throw JestUtils.specificException(() -> "Fetching message count failed for indices " + indices, response.error);
}
total += response.searchResult.getTotal();
}
return total;
}
}
代码示例来源:origin: spring-projects/spring-data-elasticsearch
private SearchRequest prepareScroll(Query query, long scrollTimeInMillis) {
SearchRequest request = new SearchRequest(toArray(query.getIndices()));
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
request.types(toArray(query.getTypes()));
request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis));
if (query.getPageable().isPaged()) {
searchSourceBuilder.size(query.getPageable().getPageSize());
}
if (!isEmpty(query.getFields())) {
searchSourceBuilder.fetchSource(toArray(query.getFields()), null);
}
request.source(searchSourceBuilder);
return request;
}
代码示例来源:origin: Netflix/conductor
searchSourceBuilder.query(queryBuilder);
searchSourceBuilder.from(start);
searchSourceBuilder.size(size);
代码示例来源:origin: spring-projects/spring-data-elasticsearch
searchSourceBuilder.size(pageable.getPageSize());
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* The number of search hits to return. Defaults to {@code 10}.
*/
public SearchRequestBuilder setSize(int size) {
sourceBuilder().size(size);
return this;
}
代码示例来源:origin: spring-projects/spring-data-elasticsearch
sourceBuilder.size(query.getPageable().getPageSize());
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* The scroll size to control number of documents processed per batch
*/
public DeleteByQueryRequest setBatchSize(int size) {
getSearchRequest().source().size(size);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Gets the batch size for this request
*/
public int getBatchSize() {
return getSearchRequest().source().size();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Sets the scroll size for setting how many documents are to be processed in one batch during reindex
*/
public ReindexRequest setSourceBatchSize(int size) {
this.getSearchRequest().source().size(size);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* The scroll size to control number of documents processed per batch
*/
public UpdateByQueryRequest setBatchSize(int size) {
getSearchRequest().source().size(size);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Gets the batch size for this request
*/
public int getBatchSize() {
return getSearchRequest().source().size();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Constructor for actual use.
*
* @param searchRequest the search request to execute to get the documents to process
* @param setDefaults should this request set the defaults on the search request? Usually set to true but leave it false to support
* request slicing
*/
public AbstractBulkByScrollRequest(SearchRequest searchRequest, boolean setDefaults) {
this.searchRequest = searchRequest;
// Set the defaults which differ from SearchRequest's defaults.
if (setDefaults) {
searchRequest.scroll(DEFAULT_SCROLL_TIMEOUT);
searchRequest.source(new SearchSourceBuilder());
searchRequest.source().size(DEFAULT_SCROLL_SIZE);
}
}
代码示例来源:origin: komoot/photon
public long count() {
return this.esClient.search(Requests.searchRequest(indexName).types(indexType).source(SearchSourceBuilder.searchSource().size(0))).actionGet().getHits()
.getTotalHits();
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
SearchRequest searchRequest = new SearchRequest();
/*
* We have to pull out the call to `source().size(size)` because
* _update_by_query and _delete_by_query uses this same parsing
* path but sets a different variable when it sees the `size`
* url parameter.
*
* Note that we can't use `searchRequest.source()::size` because
* `searchRequest.source()` is null right now. We don't have to
* guard against it being null in the IntConsumer because it can't
* be null later. If that is confusing to you then you are in good
* company.
*/
IntConsumer setSize = size -> searchRequest.source().size(size);
request.withContentOrSourceParamParserOrNull(parser ->
parseSearchRequest(searchRequest, request, parser, setSize));
return channel -> client.search(searchRequest, new RestStatusToXContentListener<>(channel));
}
代码示例来源: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);
}
};
}
内容来源于网络,如有侵权,请联系作者删除!