Search in sources :

Example 1 with PercentilesAggregationBuilder

use of org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder in project elasticsearch by elastic.

the class PercentilesTests method createTestAggregatorBuilder.

@Override
protected PercentilesAggregationBuilder createTestAggregatorBuilder() {
    PercentilesAggregationBuilder factory = new PercentilesAggregationBuilder(randomAsciiOfLengthBetween(1, 20));
    if (randomBoolean()) {
        factory.keyed(randomBoolean());
    }
    if (randomBoolean()) {
        int percentsSize = randomIntBetween(1, 20);
        double[] percents = new double[percentsSize];
        for (int i = 0; i < percentsSize; i++) {
            percents[i] = randomDouble() * 100;
        }
        factory.percentiles(percents);
    }
    if (randomBoolean()) {
        factory.numberOfSignificantValueDigits(randomIntBetween(0, 5));
    }
    if (randomBoolean()) {
        factory.compression(randomIntBetween(1, 50000));
    }
    String field = randomNumericField();
    int randomFieldBranch = randomInt(3);
    switch(randomFieldBranch) {
        case 0:
            factory.field(field);
            break;
        case 1:
            factory.field(field);
            factory.script(new Script("_value + 1"));
            break;
        case 2:
            factory.script(new Script("doc[" + field + "] + 1"));
            break;
    }
    if (randomBoolean()) {
        factory.missing("MISSING");
    }
    if (randomBoolean()) {
        factory.format("###.00");
    }
    return factory;
}
Also used : Script(org.elasticsearch.script.Script) PercentilesAggregationBuilder(org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder)

Example 2 with PercentilesAggregationBuilder

use of org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder in project vertexium by visallo.

the class ElasticsearchSearchQueryBase method getElasticsearchPercentilesAggregations.

protected List<AbstractAggregationBuilder> getElasticsearchPercentilesAggregations(PercentilesAggregation agg) {
    String propertyName = getSearchIndex().addVisibilityToPropertyName(getGraph(), agg.getFieldName(), agg.getVisibility());
    String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromPropertyName(propertyName);
    String aggName = createAggregationName(agg.getAggregationName(), visibilityHash);
    PercentilesAggregationBuilder percentilesAgg = AggregationBuilders.percentiles(aggName);
    percentilesAgg.field(propertyName);
    if (agg.getPercents() != null && agg.getPercents().length > 0) {
        percentilesAgg.percentiles(agg.getPercents());
    }
    return Collections.singletonList(percentilesAgg);
}
Also used : PercentilesAggregationBuilder(org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder)

Example 3 with PercentilesAggregationBuilder

use of org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder in project graylog2-server by Graylog2.

the class ESPercentilesHandler method doCreateAggregation.

@Nonnull
@Override
public Optional<AggregationBuilder> doCreateAggregation(String name, Pivot pivot, Percentile percentileSpec, ESPivot searchTypeHandler, ESGeneratedQueryContext queryContext) {
    final PercentilesAggregationBuilder percentiles = AggregationBuilders.percentiles(name).field(percentileSpec.field()).percentiles(percentileSpec.percentile());
    record(queryContext, pivot, percentileSpec, name, PercentilesAggregation.class);
    return Optional.of(percentiles);
}
Also used : PercentilesAggregationBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder) Nonnull(javax.annotation.Nonnull)

Aggregations

PercentilesAggregationBuilder (org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder)2 Nonnull (javax.annotation.Nonnull)1 Script (org.elasticsearch.script.Script)1 PercentilesAggregationBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder)1