当前位置: 首页>>代码示例>>Java>>正文


Java InternalAggregations类代码示例

本文整理汇总了Java中org.elasticsearch.search.aggregations.InternalAggregations的典型用法代码示例。如果您正苦于以下问题:Java InternalAggregations类的具体用法?Java InternalAggregations怎么用?Java InternalAggregations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InternalAggregations类属于org.elasticsearch.search.aggregations包,在下文中一共展示了InternalAggregations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PercolateShardResponse

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public PercolateShardResponse(BytesRef[] matches, List<Map<String, HighlightField>> hls, long count, float[] scores, PercolateContext context, ShardId shardId) {
    super(shardId);
    this.matches = matches;
    this.hls = hls;
    this.count = count;
    this.scores = scores;
    this.percolatorTypeId = context.percolatorTypeId;
    this.requestedSize = context.size();
    QuerySearchResult result = context.queryResult();
    if (result != null) {
        if (result.aggregations() != null) {
            this.aggregations = (InternalAggregations) result.aggregations();
        }
        this.pipelineAggregators = result.pipelineAggregators();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:PercolateShardResponse.java

示例2: reduce

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
@Override
public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext reduceContext) {
    MultiBucketsAggregation histo = (MultiBucketsAggregation) aggregation;
    List<? extends Bucket> buckets = histo.getBuckets();
    HistogramFactory factory = (HistogramFactory) histo;

    List<Bucket> newBuckets = new ArrayList<>();
    double sum = 0;
    for (Bucket bucket : buckets) {
        Double thisBucketValue = resolveBucketValue(histo, bucket, bucketsPaths()[0], GapPolicy.INSERT_ZEROS);
        sum += thisBucketValue;
        List<InternalAggregation> aggs = StreamSupport.stream(bucket.getAggregations().spliterator(), false).map((p) -> {
            return (InternalAggregation) p;
        }).collect(Collectors.toList());
        aggs.add(new InternalSimpleValue(name(), sum, formatter, new ArrayList<PipelineAggregator>(), metaData()));
        Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs));
        newBuckets.add(newBucket);
    }
    return factory.createAggregation(newBuckets);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:CumulativeSumPipelineAggregator.java

示例3: ReducedQueryPhase

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
ReducedQueryPhase(long totalHits, long fetchHits, float maxScore, boolean timedOut, Boolean terminatedEarly,
                         QuerySearchResult oneResult, Suggest suggest, InternalAggregations aggregations,
                         SearchProfileShardResults shardResults, int numReducePhases) {
    if (numReducePhases <= 0) {
        throw new IllegalArgumentException("at least one reduce phase must have been applied but was: " + numReducePhases);
    }
    this.totalHits = totalHits;
    this.fetchHits = fetchHits;
    if (Float.isInfinite(maxScore)) {
        this.maxScore = Float.NaN;
    } else {
        this.maxScore = maxScore;
    }
    this.timedOut = timedOut;
    this.terminatedEarly = terminatedEarly;
    this.oneResult = oneResult;
    this.suggest = suggest;
    this.aggregations = aggregations;
    this.shardResults = shardResults;
    this.numReducePhases = numReducePhases;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SearchPhaseController.java

示例4: reduce

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public B reduce(List<B> buckets, ReduceContext context) {
    long docCount = 0;
    // For the per term doc count error we add up the errors from the
    // shards that did not respond with the term. To do this we add up
    // the errors from the shards that did respond with the terms and
    // subtract that from the sum of the error from all shards
    long docCountError = 0;
    List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
    for (B bucket : buckets) {
        docCount += bucket.docCount;
        if (docCountError != -1) {
            if (bucket.docCountError == -1) {
                docCountError = -1;
            } else {
                docCountError += bucket.docCountError;
            }
        }
        aggregationsList.add(bucket.aggregations);
    }
    InternalAggregations aggs = InternalAggregations.reduce(aggregationsList, context);
    return newBucket(docCount, aggs, docCountError);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:InternalTerms.java

示例5: testConsumerConcurrently

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public void testConsumerConcurrently() throws InterruptedException {
    int expectedNumResults = randomIntBetween(1, 100);
    int bufferSize = randomIntBetween(2, 200);

    SearchRequest request = new SearchRequest();
    request.source(new SearchSourceBuilder().aggregation(AggregationBuilders.avg("foo")));
    request.setBatchedReduceSize(bufferSize);
    InitialSearchPhase.SearchPhaseResults<QuerySearchResultProvider> consumer =
        searchPhaseController.newSearchPhaseResults(request, expectedNumResults);
    AtomicInteger max = new AtomicInteger();
    CountDownLatch latch = new CountDownLatch(expectedNumResults);
    for (int i = 0; i < expectedNumResults; i++) {
        int id = i;
        Thread t = new Thread(() -> {
            int number = randomIntBetween(1, 1000);
            max.updateAndGet(prev -> Math.max(prev, number));
            QuerySearchResult result = new QuerySearchResult(id, new SearchShardTarget("node", new Index("a", "b"), id));
            result.topDocs(new TopDocs(id, new ScoreDoc[0], 0.0F), new DocValueFormat[0]);
            InternalAggregations aggs = new InternalAggregations(Arrays.asList(new InternalMax("test", (double) number,
                DocValueFormat.RAW, Collections.emptyList(), Collections.emptyMap())));
            result.aggregations(aggs);
            consumer.consumeResult(id, result);
            latch.countDown();

        });
        t.start();
    }
    latch.await();
    SearchPhaseController.ReducedQueryPhase reduce = consumer.reduce();
    InternalMax internalMax = (InternalMax) reduce.aggregations.asList().get(0);
    assertEquals(max.get(), internalMax.getValue(), 0.0D);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:SearchPhaseControllerTests.java

示例6: reduce

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public B reduce(List<B> buckets, ReduceContext context) {
    long subsetDf = 0;
    long supersetDf = 0;
    List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
    for (B bucket : buckets) {
        subsetDf += bucket.subsetDf;
        supersetDf += bucket.supersetDf;
        aggregationsList.add(bucket.aggregations);
    }
    InternalAggregations aggs = InternalAggregations.reduce(aggregationsList, context);
    return newBucket(subsetDf, subsetSize, supersetDf, supersetSize, aggs);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:InternalSignificantTerms.java

示例7: Bucket

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public Bucket(DocValueFormat format, boolean keyed, String key, BytesRef from, BytesRef to,
        long docCount, InternalAggregations aggregations) {
    this.format = format;
    this.keyed = keyed;
    this.key = key;
    this.from = from;
    this.to = to;
    this.docCount = docCount;
    this.aggregations = aggregations;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:InternalBinaryRange.java

示例8: Bucket

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public Bucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed,
        DocValueFormat formatter) {
    this(keyed, formatter);
    this.key = key != null ? key : generateKey(from, to, formatter);
    this.from = from;
    this.to = to;
    this.docCount = docCount;
    this.aggregations = aggregations;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:InternalRange.java

示例9: reduce

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
Bucket reduce(List<Bucket> ranges, ReduceContext context) {
    long docCount = 0;
    List<InternalAggregations> aggregationsList = new ArrayList<>(ranges.size());
    for (Bucket range : ranges) {
        docCount += range.docCount;
        aggregationsList.add(range.aggregations);
    }
    final InternalAggregations aggs = InternalAggregations.reduce(aggregationsList, context);
    return getFactory().createBucket(key, from, to, docCount, aggs, keyed, format);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:InternalRange.java

示例10: InternalSearchResponse

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public InternalSearchResponse(InternalSearchHits hits, InternalAggregations aggregations, Suggest suggest,
                              InternalProfileShardResults profileResults, boolean timedOut, Boolean terminatedEarly) {
    this.hits = hits;
    this.aggregations = aggregations;
    this.suggest = suggest;
    this.profileResults = profileResults;
    this.timedOut = timedOut;
    this.terminatedEarly = terminatedEarly;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:InternalSearchResponse.java

示例11: reduce

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public Bucket reduce(List<? extends Bucket> buckets, ReduceContext context) {
    List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
    long docCount = 0;
    for (Bucket bucket : buckets) {
        docCount += bucket.docCount;
        aggregationsList.add(bucket.aggregations);
    }
    final InternalAggregations aggs = InternalAggregations.reduce(aggregationsList, context);
    return new Bucket(geohashAsLong, docCount, aggs);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:InternalGeoHashGrid.java

示例12: Bucket

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
public Bucket(long key, long docCount, boolean keyed, ValueFormatter formatter, Factory factory,
        InternalAggregations aggregations) {
    this(keyed, formatter, factory);
    this.key = key;
    this.docCount = docCount;
    this.aggregations = aggregations;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:InternalHistogram.java

示例13: Bucket

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
/**
 * Read from a stream.
 */
protected Bucket(StreamInput in, DocValueFormat formatter, boolean showDocCountError) throws IOException {
    this.showDocCountError = showDocCountError;
    this.format = formatter;
    docCount = in.readVLong();
    docCountError = -1;
    if (showDocCountError) {
        docCountError = in.readLong();
    }
    aggregations = InternalAggregations.readAggregations(in);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:InternalTerms.java

示例14: readFrom

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    termBytes = in.readBytesRef();
    subsetDf = in.readVLong();
    supersetDf = in.readVLong();
    score = in.readDouble();
    aggregations = InternalAggregations.readAggregations(in);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:SignificantStringTerms.java

示例15: readFrom

import org.elasticsearch.search.aggregations.InternalAggregations; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    subsetDf = in.readVLong();
    supersetDf = in.readVLong();
    term = in.readLong();
    score = in.readDouble();
    aggregations = InternalAggregations.readAggregations(in);

}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:SignificantLongTerms.java


注:本文中的org.elasticsearch.search.aggregations.InternalAggregations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。