Search in sources :

Example 16 with GlobalAggregationBuilder

use of org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder in project fess by codelibs.

the class BsClickLogCA method global.

public void global(String name, ConditionOptionCall<GlobalAggregationBuilder> opLambda, OperatorCall<BsClickLogCA> aggsLambda) {
    GlobalAggregationBuilder builder = regGlobalA(name);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
    if (aggsLambda != null) {
        ClickLogCA ca = new ClickLogCA();
        aggsLambda.callback(ca);
        ca.getAggregationBuilderList().forEach(builder::subAggregation);
    }
}
Also used : GlobalAggregationBuilder(org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder) ClickLogCA(org.codelibs.fess.es.log.cbean.ca.ClickLogCA)

Example 17 with GlobalAggregationBuilder

use of org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder in project fess by codelibs.

the class BsGroupCA method global.

public void global(String name, ConditionOptionCall<GlobalAggregationBuilder> opLambda, OperatorCall<BsGroupCA> aggsLambda) {
    GlobalAggregationBuilder builder = regGlobalA(name);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
    if (aggsLambda != null) {
        GroupCA ca = new GroupCA();
        aggsLambda.callback(ca);
        ca.getAggregationBuilderList().forEach(builder::subAggregation);
    }
}
Also used : GroupCA(org.codelibs.fess.es.user.cbean.ca.GroupCA) GlobalAggregationBuilder(org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder)

Example 18 with GlobalAggregationBuilder

use of org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder in project fess by codelibs.

the class BsRoleCA method global.

public void global(String name, ConditionOptionCall<GlobalAggregationBuilder> opLambda, OperatorCall<BsRoleCA> aggsLambda) {
    GlobalAggregationBuilder builder = regGlobalA(name);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
    if (aggsLambda != null) {
        RoleCA ca = new RoleCA();
        aggsLambda.callback(ca);
        ca.getAggregationBuilderList().forEach(builder::subAggregation);
    }
}
Also used : RoleCA(org.codelibs.fess.es.user.cbean.ca.RoleCA) GlobalAggregationBuilder(org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder)

Example 19 with GlobalAggregationBuilder

use of org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder in project elasticsearch by elastic.

the class GlobalAggregatorTests method testCase.

// Note that `global`'s fancy support for ignoring the query comes from special code in AggregationPhase. We don't test that here.
private void testCase(CheckedConsumer<RandomIndexWriter, IOException> buildIndex, BiConsumer<InternalGlobal, InternalMin> verify) throws IOException {
    Directory directory = newDirectory();
    RandomIndexWriter indexWriter = new RandomIndexWriter(random(), directory);
    buildIndex.accept(indexWriter);
    indexWriter.close();
    IndexReader indexReader = DirectoryReader.open(directory);
    IndexSearcher indexSearcher = newSearcher(indexReader, true, true);
    GlobalAggregationBuilder aggregationBuilder = new GlobalAggregationBuilder("_name");
    aggregationBuilder.subAggregation(new MinAggregationBuilder("in_global").field("number"));
    MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
    fieldType.setName("number");
    try (GlobalAggregator aggregator = createAggregator(aggregationBuilder, indexSearcher, fieldType)) {
        try {
            aggregator.preCollection();
            indexSearcher.search(new MatchAllDocsQuery(), aggregator);
            aggregator.postCollection();
            InternalGlobal result = (InternalGlobal) aggregator.buildAggregation(0L);
            verify.accept(result, (InternalMin) result.getAggregations().asMap().get("in_global"));
        } finally {
            IOUtils.close(aggregator.subAggregators());
        }
    }
    indexReader.close();
    directory.close();
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) InternalGlobal(org.elasticsearch.search.aggregations.bucket.global.InternalGlobal) IndexReader(org.apache.lucene.index.IndexReader) MinAggregationBuilder(org.elasticsearch.search.aggregations.metrics.min.MinAggregationBuilder) MappedFieldType(org.elasticsearch.index.mapper.MappedFieldType) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) RandomIndexWriter(org.apache.lucene.index.RandomIndexWriter) Directory(org.apache.lucene.store.Directory) GlobalAggregationBuilder(org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder) GlobalAggregator(org.elasticsearch.search.aggregations.bucket.global.GlobalAggregator)

Example 20 with GlobalAggregationBuilder

use of org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder in project fess by codelibs.

the class EsAbstractConditionAggregation method regGlobalA.

protected GlobalAggregationBuilder regGlobalA(String name) {
    GlobalAggregationBuilder builder = AggregationBuilders.global(name);
    regA(builder);
    return builder;
}
Also used : GlobalAggregationBuilder(org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder)

Aggregations

GlobalAggregationBuilder (org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder)42 IndexReader (org.apache.lucene.index.IndexReader)1 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1 Directory (org.apache.lucene.store.Directory)1 AccessTokenCA (org.codelibs.fess.es.config.cbean.ca.AccessTokenCA)1 BadWordCA (org.codelibs.fess.es.config.cbean.ca.BadWordCA)1 BoostDocumentRuleCA (org.codelibs.fess.es.config.cbean.ca.BoostDocumentRuleCA)1 CrawlingInfoCA (org.codelibs.fess.es.config.cbean.ca.CrawlingInfoCA)1 CrawlingInfoParamCA (org.codelibs.fess.es.config.cbean.ca.CrawlingInfoParamCA)1 DataConfigCA (org.codelibs.fess.es.config.cbean.ca.DataConfigCA)1 DataConfigToLabelCA (org.codelibs.fess.es.config.cbean.ca.DataConfigToLabelCA)1 DataConfigToRoleCA (org.codelibs.fess.es.config.cbean.ca.DataConfigToRoleCA)1 DuplicateHostCA (org.codelibs.fess.es.config.cbean.ca.DuplicateHostCA)1 ElevateWordCA (org.codelibs.fess.es.config.cbean.ca.ElevateWordCA)1 ElevateWordToLabelCA (org.codelibs.fess.es.config.cbean.ca.ElevateWordToLabelCA)1 FailureUrlCA (org.codelibs.fess.es.config.cbean.ca.FailureUrlCA)1 FileAuthenticationCA (org.codelibs.fess.es.config.cbean.ca.FileAuthenticationCA)1 FileConfigCA (org.codelibs.fess.es.config.cbean.ca.FileConfigCA)1