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;
}
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);
}
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);
}
Aggregations