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


Java AggregatorFactory类代码示例

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


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

示例1: doValidate

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
    if (bucketsPaths.length != 1) {
        throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
                + " must contain a single entry for aggregation [" + name + "]");
    }
    if (!(parent instanceof HistogramAggregator.Factory)) {
        throw new IllegalStateException("cumulative sum aggregation [" + name
                + "] must have a histogram or date_histogram as parent");
    } else {
        HistogramAggregator.Factory histoParent = (HistogramAggregator.Factory) parent;
        if (histoParent.minDocCount() != 0) {
            throw new IllegalStateException("parent histogram of cumulative sum aggregation [" + name
                    + "] must have min_doc_count of 0");
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:CumulativeSumPipelineAggregator.java

示例2: doBuild

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
protected ScriptedMetricAggregatorFactory doBuild(SearchContext context, AggregatorFactory<?> parent,
        Builder subfactoriesBuilder) throws IOException {

    QueryShardContext queryShardContext = context.getQueryShardContext();
    Function<Map<String, Object>, ExecutableScript> executableInitScript;
    if (initScript != null) {
        executableInitScript = queryShardContext.getLazyExecutableScript(initScript, ScriptContext.Standard.AGGS);
    } else {
        executableInitScript = (p) -> null;
    }
    Function<Map<String, Object>, SearchScript> searchMapScript = queryShardContext.getLazySearchScript(mapScript,
        ScriptContext.Standard.AGGS);
    Function<Map<String, Object>, ExecutableScript> executableCombineScript;
    if (combineScript != null) {
        executableCombineScript = queryShardContext.getLazyExecutableScript(combineScript, ScriptContext.Standard.AGGS);
    } else {
        executableCombineScript = (p) -> null;
    }
    return new ScriptedMetricAggregatorFactory(name, searchMapScript, executableInitScript, executableCombineScript, reduceScript,
            params, context, parent, subfactoriesBuilder, metaData);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ScriptedMetricAggregationBuilder.java

示例3: doBuild

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
protected TopHitsAggregatorFactory doBuild(SearchContext context, AggregatorFactory<?> parent, Builder subfactoriesBuilder)
        throws IOException {
    List<ScriptFieldsContext.ScriptField> fields = new ArrayList<>();
    if (scriptFields != null) {
        for (ScriptField field : scriptFields) {
            SearchScript searchScript = context.getQueryShardContext().getSearchScript(field.script(),
                ScriptContext.Standard.SEARCH);
            fields.add(new org.elasticsearch.search.fetch.subphase.ScriptFieldsContext.ScriptField(
                field.fieldName(), searchScript, field.ignoreFailure()));
        }
    }

    final Optional<SortAndFormats> optionalSort;
    if (sorts == null) {
        optionalSort = Optional.empty();
    } else {
        optionalSort = SortBuilder.buildSort(sorts, context.getQueryShardContext());
    }
    return new TopHitsAggregatorFactory(name, from, size, explain, version, trackScores, optionalSort, highlightBuilder,
            storedFieldsContext, fieldDataFields, fields, fetchSourceContext, context, parent, subfactoriesBuilder, metaData);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:TopHitsAggregationBuilder.java

示例4: doValidate

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories,
        List<PipelineAggregatorFactory> pipelineAggregatoractories) {
    if (bucketsPaths.length != 1) {
        throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
                + " must contain a single entry for aggregation [" + name + "]");
    }
    if (!(parent instanceof HistogramAggregator.Factory)) {
        throw new IllegalStateException("moving average aggregation [" + name
                + "] must have a histogram or date_histogram as parent");
    } else {
        HistogramAggregator.Factory histoParent = (HistogramAggregator.Factory) parent;
        if (histoParent.minDocCount() != 0) {
            throw new IllegalStateException("parent histogram of moving average aggregation [" + name
                    + "] must have min_doc_count of 0");
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:MovAvgPipelineAggregator.java

示例5: SignificantTermsAggregatorFactory

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude,
        String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds,
        SignificanceHeuristic significanceHeuristic, SearchContext context, AggregatorFactory<?> parent,
        AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
    super(name, config, context, parent, subFactoriesBuilder, metaData);
    this.includeExclude = includeExclude;
    this.executionHint = executionHint;
    this.filter = filterBuilder == null
            ? null
            : filterBuilder.toQuery(context.getQueryShardContext());
    IndexSearcher searcher = context.searcher();
    this.supersetNumDocs = filter == null
            // Important - need to use the doc count that includes deleted docs
            // or we have this issue: https://github.com/elastic/elasticsearch/issues/7951
            ? searcher.getIndexReader().maxDoc()
            : searcher.count(filter);
    this.bucketCountThresholds = bucketCountThresholds;
    this.significanceHeuristic = significanceHeuristic;
    setFieldInfo(context);

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SignificantTermsAggregatorFactory.java

示例6: parse

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
    String path = null;

    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token == XContentParser.Token.VALUE_STRING) {
            if ("path".equals(currentFieldName)) {
                path = parser.text();
            } else {
                throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: ["
                        + currentFieldName + "].", parser.getTokenLocation());
            }
        } else {
            throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].",
                    parser.getTokenLocation());
        }
    }

    return new ReverseNestedAggregator.Factory(aggregationName, path);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:ReverseNestedParser.java

示例7: parse

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

    ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, InternalValueCount.TYPE, context)
            .build();

    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (!vsParser.token(currentFieldName, token, parser)) {
            throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].",
                    parser.getTokenLocation());
        }
    }

    return new ValueCountAggregator.Factory(aggregationName, vsParser.config());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:ValueCountParser.java

示例8: resolveValuesSourceConfigFromAncestors

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
private void resolveValuesSourceConfigFromAncestors(String aggName, AggregatorFactory parent, Class<VS> requiredValuesSourceType) {
    ValuesSourceConfig config;
    while (parent != null) {
        if (parent instanceof ValuesSourceAggregatorFactory) {
            config = ((ValuesSourceAggregatorFactory) parent).config;
            if (config != null && config.valid()) {
                if (requiredValuesSourceType == null || requiredValuesSourceType.isAssignableFrom(config.valueSourceType)) {
                    ValueFormat format = config.format;
                    this.config = config;
                    // if the user explicitly defined a format pattern, we'll do our best to keep it even when we inherit the
                    // value source form one of the ancestor aggregations
                    if (this.config.formatPattern != null && format != null && format instanceof ValueFormat.Patternable) {
                        this.config.format = ((ValueFormat.Patternable) format).create(this.config.formatPattern);
                    }
                    return;
                }
            }
        }
        parent = parent.parent();
    }
    throw new AggregationExecutionException("could not find the appropriate value context to perform aggregation [" + aggName + "]");
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:ValuesSourceAggregatorFactory.java

示例9: parse

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
    ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoCentroid.TYPE, context)
            .targetValueType(ValueType.GEOPOINT)
            .formattable(true)
            .build();
    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (vsParser.token(currentFieldName, token, parser)) {
            continue;
        } else {
            throw new SearchParseException(context, "Unknown key for a " + token + " in aggregation [" + aggregationName + "]: ["
                    + currentFieldName + "].", parser.getTokenLocation());
        }
    }
    return new GeoCentroidAggregator.Factory(aggregationName, vsParser.config());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:GeoCentroidParser.java

示例10: doBuild

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
protected AggregatorFactory<?> doBuild(SearchContext context, AggregatorFactory<?> parent, Builder subFactoriesBuilder)
        throws IOException {
    int maxFilters = context.indexShard().indexSettings().getMaxAdjacencyMatrixFilters();
    if (filters.size() > maxFilters){
        throw new QueryPhaseExecutionException(context,
                "Number of filters is too large, must be less than or equal to: [" + maxFilters + "] but was ["
                        + filters.size() + "]."
                        + "This limit can be set by changing the [" + IndexSettings.MAX_ADJACENCY_MATRIX_FILTERS_SETTING.getKey()
                        + "] index level setting.");
    }

    List<KeyedFilter> rewrittenFilters = new ArrayList<>();
    for (KeyedFilter kf : filters) {
        rewrittenFilters.add(new KeyedFilter(kf.key(), QueryBuilder.rewriteQuery(kf.filter(), context.getQueryShardContext())));
    }

    return new AdjacencyMatrixAggregatorFactory(name, rewrittenFilters, separator, context, parent,
            subFactoriesBuilder, metaData);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:AdjacencyMatrixAggregationBuilder.java

示例11: parse

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

    ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, aggType, context).formattable(true)
            .build();

    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (!vsParser.token(currentFieldName, token, parser)) {
            throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].",
                    parser.getTokenLocation());
        }
    }

    return createFactory(aggregationName, vsParser.config());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:NumericValuesSourceMetricsAggregatorParser.java

示例12: FiltersAggregatorFactory

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
public FiltersAggregatorFactory(String name, List<KeyedFilter> filters, boolean keyed, boolean otherBucket,
        String otherBucketKey, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactories,
        Map<String, Object> metaData) throws IOException {
    super(name, context, parent, subFactories, metaData);
    this.keyed = keyed;
    this.otherBucket = otherBucket;
    this.otherBucketKey = otherBucketKey;
    IndexSearcher contextSearcher = context.searcher();
    weights = new Weight[filters.size()];
    keys = new String[filters.size()];
    for (int i = 0; i < filters.size(); ++i) {
        KeyedFilter keyedFilter = filters.get(i);
        this.keys[i] = keyedFilter.key();
        Query filter = keyedFilter.filter().toFilter(context.getQueryShardContext());
        this.weights[i] = contextSearcher.createNormalizedWeight(filter, false);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:FiltersAggregatorFactory.java

示例13: innerInnerBuild

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
protected MultiValuesSourceAggregatorFactory<Numeric, ?> innerInnerBuild(
    final SearchContext context,
    final List<NamedValuesSourceConfigSpec<Numeric>> configs, final MultiValueMode multiValueMode,
    final AggregatorFactory<?> parent, final Builder subFactoriesBuilder) throws IOException {
  if (this.inputs == null || this.inputs.length != configs.size() - 1) {
    throw new IllegalArgumentException(
        "[inputs] must have [" + (configs.size() - 1)
            + "] values as much as the number of feature fields: ["
            + this.name
            + "]");
  }
  return new PredictionAggregatorFactory(this.name, configs, multiValueMode, this.inputs,
      context,
      parent,
      subFactoriesBuilder, this.metaData);
}
 
开发者ID:scaleborn,项目名称:elasticsearch-linear-regression,代码行数:18,代码来源:PredictionAggregationBuilder.java

示例14: doBuild

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
@Override
protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent,
        AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
    Map<String, ValuesSourceConfig<VS>> configs = resolveConfig(context);
    MultiValuesSourceAggregatorFactory<VS, ?> factory = innerBuild(context, configs, parent, subFactoriesBuilder);
    return factory;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:MultiValuesSourceAggregationBuilder.java

示例15: ScriptedMetricAggregatorFactory

import org.elasticsearch.search.aggregations.AggregatorFactory; //导入依赖的package包/类
public ScriptedMetricAggregatorFactory(String name, Function<Map<String, Object>, SearchScript> mapScript,
        Function<Map<String, Object>, ExecutableScript> initScript, Function<Map<String, Object>, ExecutableScript> combineScript,
        Script reduceScript, Map<String, Object> params, SearchContext context, AggregatorFactory<?> parent,
        AggregatorFactories.Builder subFactories, Map<String, Object> metaData) throws IOException {
    super(name, context, parent, subFactories, metaData);
    this.mapScript = mapScript;
    this.initScript = initScript;
    this.combineScript = combineScript;
    this.reduceScript = reduceScript;
    this.params = params;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ScriptedMetricAggregatorFactory.java


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