Search in sources :

Example 1 with WithOrdinals

use of org.opensearch.search.aggregations.support.ValuesSource.Bytes.WithOrdinals in project OpenSearch by opensearch-project.

the class ParentAggregatorFactory method doCreateInternal.

@Override
protected Aggregator doCreateInternal(SearchContext searchContext, Aggregator children, CardinalityUpperBound cardinality, Map<String, Object> metadata) throws IOException {
    ValuesSource rawValuesSource = config.getValuesSource();
    if (rawValuesSource instanceof WithOrdinals == false) {
        throw new AggregationExecutionException("ValuesSource type " + rawValuesSource.toString() + "is not supported for aggregation " + this.name());
    }
    WithOrdinals valuesSource = (WithOrdinals) rawValuesSource;
    long maxOrd = valuesSource.globalMaxOrd(searchContext.searcher());
    return new ChildrenToParentAggregator(name, factories, searchContext, children, childFilter, parentFilter, valuesSource, maxOrd, cardinality, metadata);
}
Also used : WithOrdinals(org.opensearch.search.aggregations.support.ValuesSource.Bytes.WithOrdinals) ValuesSource(org.opensearch.search.aggregations.support.ValuesSource) AggregationExecutionException(org.opensearch.search.aggregations.AggregationExecutionException)

Example 2 with WithOrdinals

use of org.opensearch.search.aggregations.support.ValuesSource.Bytes.WithOrdinals in project OpenSearch by opensearch-project.

the class ChildrenAggregatorFactory method doCreateInternal.

@Override
protected Aggregator doCreateInternal(SearchContext searchContext, Aggregator parent, CardinalityUpperBound cardinality, Map<String, Object> metadata) throws IOException {
    ValuesSource rawValuesSource = config.getValuesSource();
    if (rawValuesSource instanceof WithOrdinals == false) {
        throw new AggregationExecutionException("ValuesSource type " + rawValuesSource.toString() + "is not supported for aggregation " + this.name());
    }
    WithOrdinals valuesSource = (WithOrdinals) rawValuesSource;
    long maxOrd = valuesSource.globalMaxOrd(searchContext.searcher());
    return new ParentToChildrenAggregator(name, factories, searchContext, parent, childFilter, parentFilter, valuesSource, maxOrd, cardinality, metadata);
}
Also used : WithOrdinals(org.opensearch.search.aggregations.support.ValuesSource.Bytes.WithOrdinals) ValuesSource(org.opensearch.search.aggregations.support.ValuesSource) AggregationExecutionException(org.opensearch.search.aggregations.AggregationExecutionException)

Aggregations

AggregationExecutionException (org.opensearch.search.aggregations.AggregationExecutionException)2 ValuesSource (org.opensearch.search.aggregations.support.ValuesSource)2 WithOrdinals (org.opensearch.search.aggregations.support.ValuesSource.Bytes.WithOrdinals)2