本文整理汇总了Java中org.elasticsearch.search.aggregations.bucket.global.GlobalBuilder类的典型用法代码示例。如果您正苦于以下问题:Java GlobalBuilder类的具体用法?Java GlobalBuilder怎么用?Java GlobalBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GlobalBuilder类属于org.elasticsearch.search.aggregations.bucket.global包,在下文中一共展示了GlobalBuilder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: global
import org.elasticsearch.search.aggregations.bucket.global.GlobalBuilder; //导入依赖的package包/类
/**
* Create a new {@link Global} aggregation with the given name.
*/
public static GlobalBuilder global(String name) {
return new GlobalBuilder(name);
}
示例2: createTermsBuilder
import org.elasticsearch.search.aggregations.bucket.global.GlobalBuilder; //导入依赖的package包/类
/**
* Create "terms aggregation" which can be [optionally] nested in "filtered aggregation" if any filters
* are used and always nested in "global filter".
*
* Nesting of aggregations. First comes the global aggregation, first-level nested
* is filter aggregation and second-level nested is terms aggregation.
* <pre>
* {
* "aggs" : {
* "aggregationName" : {
* "global" : {},
* // if any filters from searchFilters apply
* "aggs" : {
* "aggregationName_filter" : {
* "filter" : { _filters_ },
* // buckets
* "aggs" : {
* "aggregationName_buckets" : {
* "terms" : {
* "field" : ... ,
* "size" : ...
* }
* }
* }
* }
* }
* }
* }
* }
* </pre>
*
* @param aggregationName top level name of the aggregation
* @param aggregationField index field the aggregation buckets are calculated for
* @param size terms field size
* @param searchFilters used filters
* @param excluding if true then filters on top of aggregationField are excluded from searchFilters
* @return GlobalBuilder
*/
protected GlobalBuilder createTermsBuilder(String aggregationName, String aggregationField, int size,
Map<String, FilterBuilder> searchFilters, boolean excluding) {
FilterAggregationBuilder fab = null;
if (searchFilters != null && !searchFilters.isEmpty()) {
FilterBuilder[] fb = excluding ? filtersMapToArrayExcluding(searchFilters, aggregationField) :
filtersMapToArray(searchFilters);
if (fb != null && fb.length > 0) {
fab = AggregationBuilders.filter(aggregationName + "_filter");
fab.filter(new AndFilterBuilder(fb));
}
}
TermsBuilder tb = AggregationBuilders.terms(aggregationName+"_buckets").field(aggregationField).size(size);
GlobalBuilder gb = AggregationBuilders.global(aggregationName);
if (fab != null) {
fab.subAggregation(tb);
gb.subAggregation(fab);
} else {
gb.subAggregation(tb);
}
return gb;
}