本文整理汇总了Java中org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation类的典型用法代码示例。如果您正苦于以下问题:Java SingleBucketAggregation类的具体用法?Java SingleBucketAggregation怎么用?Java SingleBucketAggregation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SingleBucketAggregation类属于org.elasticsearch.search.aggregations.bucket包,在下文中一共展示了SingleBucketAggregation类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleAggregations
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation; //导入依赖的package包/类
private void handleAggregations(Aggregations aggregations, List<String> headers, List<List<String>> lines) throws CsvExtractorException {
if(allNumericAggregations(aggregations)){
lines.get(this.currentLineIndex).addAll(fillHeaderAndCreateLineForNumericAggregations(aggregations, headers));
return;
}
//aggregations with size one only supported when not metrics.
List<Aggregation> aggregationList = aggregations.asList();
if(aggregationList.size() > 1){
throw new CsvExtractorException("currently support only one aggregation at same level (Except for numeric metrics)");
}
Aggregation aggregation = aggregationList.get(0);
//we want to skip singleBucketAggregations (nested,reverse_nested,filters)
if(aggregation instanceof SingleBucketAggregation){
Aggregations singleBucketAggs = ((SingleBucketAggregation) aggregation).getAggregations();
handleAggregations(singleBucketAggs, headers, lines);
return;
}
if(aggregation instanceof NumericMetricsAggregation){
handleNumericMetricAggregation(headers, lines.get(currentLineIndex), aggregation);
return;
}
if(aggregation instanceof GeoBounds){
handleGeoBoundsAggregation(headers, lines, (GeoBounds) aggregation);
return;
}
if(aggregation instanceof TopHits){
//todo: handle this . it returns hits... maby back to normal?
//todo: read about this usages
// TopHits topHitsAggregation = (TopHits) aggregation;
}
if(aggregation instanceof MultiBucketsAggregation){
MultiBucketsAggregation bucketsAggregation = (MultiBucketsAggregation) aggregation;
String name = bucketsAggregation.getName();
//checking because it can comes from sub aggregation again
if(!headers.contains(name)){
headers.add(name);
}
Collection<? extends MultiBucketsAggregation.Bucket> buckets = bucketsAggregation.getBuckets();
//clone current line.
List<String> currentLine = lines.get(this.currentLineIndex);
List<String> clonedLine = new ArrayList<>(currentLine);
//call handle_Agg with current_line++
boolean firstLine = true;
for (MultiBucketsAggregation.Bucket bucket : buckets) {
//each bucket need to add new line with current line copied => except for first line
String key = bucket.getKeyAsString();
if(firstLine){
firstLine = false;
}
else {
currentLineIndex++;
currentLine = new ArrayList<String>(clonedLine);
lines.add(currentLine);
}
currentLine.add(key);
handleAggregations(bucket.getAggregations(),headers,lines);
}
}
}
开发者ID:mazhou,项目名称:es-sql,代码行数:64,代码来源:CSVResultsExtractor.java
示例2: skipAggregations
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation; //导入依赖的package包/类
private Aggregation skipAggregations(Aggregation firstAggregation) {
while(firstAggregation instanceof SingleBucketAggregation){
firstAggregation = getFirstAggregation(((SingleBucketAggregation) firstAggregation).getAggregations());
}
return firstAggregation;
}
开发者ID:mazhou,项目名称:es-sql,代码行数:7,代码来源:CSVResultsExtractor.java
示例3: handleAggregations
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation; //导入依赖的package包/类
private void handleAggregations(Aggregations aggregations, List<String> headers, List<List<Object>> lines) throws ObjectResultsExtractException {
if (allNumericAggregations(aggregations)) {
lines.get(this.currentLineIndex).addAll(fillHeaderAndCreateLineForNumericAggregations(aggregations, headers));
return;
}
//aggregations with size one only supported when not metrics.
List<Aggregation> aggregationList = aggregations.asList();
if (aggregationList.size() > 1) {
throw new ObjectResultsExtractException("currently support only one aggregation at same level (Except for numeric metrics)");
}
Aggregation aggregation = aggregationList.get(0);
//we want to skip singleBucketAggregations (nested,reverse_nested,filters)
if (aggregation instanceof SingleBucketAggregation) {
Aggregations singleBucketAggs = ((SingleBucketAggregation) aggregation).getAggregations();
handleAggregations(singleBucketAggs, headers, lines);
return;
}
if (aggregation instanceof NumericMetricsAggregation) {
handleNumericMetricAggregation(headers, lines.get(currentLineIndex), aggregation);
return;
}
if (aggregation instanceof GeoBounds) {
handleGeoBoundsAggregation(headers, lines, (GeoBounds) aggregation);
return;
}
if (aggregation instanceof TopHits) {
//todo: handle this . it returns hits... maby back to normal?
//todo: read about this usages
// TopHits topHitsAggregation = (TopHits) aggregation;
}
if (aggregation instanceof MultiBucketsAggregation) {
MultiBucketsAggregation bucketsAggregation = (MultiBucketsAggregation) aggregation;
String name = bucketsAggregation.getName();
//checking because it can comes from sub aggregation again
if (!headers.contains(name)) {
headers.add(name);
}
Collection<? extends MultiBucketsAggregation.Bucket> buckets = bucketsAggregation.getBuckets();
//clone current line.
List<Object> currentLine = lines.get(this.currentLineIndex);
List<Object> clonedLine = new ArrayList<>(currentLine);
//call handle_Agg with current_line++
boolean firstLine = true;
for (MultiBucketsAggregation.Bucket bucket : buckets) {
//each bucket need to add new line with current line copied => except for first line
String key = bucket.getKeyAsString();
if (firstLine) {
firstLine = false;
} else {
currentLineIndex++;
currentLine = new ArrayList<Object>(clonedLine);
lines.add(currentLine);
}
currentLine.add(key);
handleAggregations(bucket.getAggregations(), headers, lines);
}
}
}
开发者ID:mazhou,项目名称:es-sql,代码行数:63,代码来源:ObjectResultsExtractor.java
示例4: skipAggregations
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation; //导入依赖的package包/类
private Aggregation skipAggregations(Aggregation firstAggregation) {
while (firstAggregation instanceof SingleBucketAggregation) {
firstAggregation = getFirstAggregation(((SingleBucketAggregation) firstAggregation).getAggregations());
}
return firstAggregation;
}
开发者ID:mazhou,项目名称:es-sql,代码行数:7,代码来源:ObjectResultsExtractor.java
示例5: toSingleBucket
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation; //导入依赖的package包/类
protected Iterable<SingleBucketAggregation> toSingleBucket(Aggregations aggregations) {
return from(aggregations)
.transform(input -> (SingleBucketAggregation) input);
}
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:5,代码来源:LoadContainerStats.java
注:本文中的org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论