From f26311e88b8c8b432305b514a975db603bec326e Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Wed, 17 Jun 2015 10:48:21 +0100 Subject: [PATCH] Aggregations: Rename `series_arithmetic` agg to `bucket_script` --- .../aggregations/AggregationModule.java | 4 ++-- .../TransportAggregationModule.java | 4 ++-- .../pipeline/PipelineAggregatorBuilders.java | 6 +++--- .../BucketScriptBuilder.java} | 20 +++++++++---------- .../BucketScriptParser.java} | 8 ++++---- .../BucketScriptPipelineAggregator.java} | 16 +++++++-------- ...meticTests.java => BucketScriptTests.java} | 2 +- docs/reference/aggregations/pipeline.asciidoc | 2 +- ...doc => bucket-script-aggregation.asciidoc} | 10 +++++----- 9 files changed, 36 insertions(+), 36 deletions(-) rename core/src/main/java/org/elasticsearch/search/aggregations/pipeline/{seriesarithmetic/SeriesArithmeticBuilder.java => bucketscript/BucketScriptBuilder.java} (74%) rename core/src/main/java/org/elasticsearch/search/aggregations/pipeline/{seriesarithmetic/SeriesArithmeticParser.java => bucketscript/BucketScriptParser.java} (94%) rename core/src/main/java/org/elasticsearch/search/aggregations/pipeline/{seriesarithmetic/SeriesArithmeticPipelineAggregator.java => bucketscript/BucketScriptPipelineAggregator.java} (90%) rename core/src/test/java/org/elasticsearch/search/aggregations/pipeline/{SeriesArithmeticTests.java => BucketScriptTests.java} (99%) rename docs/reference/aggregations/pipeline/{series-arithmetic-aggregation.asciidoc => bucket-script-aggregation.asciidoc} (95%) diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java index 8e86c8b5e37..93229745496 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java @@ -61,10 +61,10 @@ import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucke import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser; import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser; import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptParser; import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser; import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelModule; -import org.elasticsearch.search.aggregations.pipeline.seriesarithmetic.SeriesArithmeticParser; import java.util.List; @@ -115,7 +115,7 @@ public class AggregationModule extends AbstractModule implements SpawnModules{ pipelineAggParsers.add(AvgBucketParser.class); pipelineAggParsers.add(SumBucketParser.class); pipelineAggParsers.add(MovAvgParser.class); - pipelineAggParsers.add(SeriesArithmeticParser.class); + pipelineAggParsers.add(BucketScriptParser.class); } /** diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java b/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java index 3a9f11f85ea..864dd829498 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java @@ -65,11 +65,11 @@ import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucke import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative; import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.movavg.models.TransportMovAvgModelModule; -import org.elasticsearch.search.aggregations.pipeline.seriesarithmetic.SeriesArithmeticPipelineAggregator; /** * A module that registers all the transport streams for the addAggregation @@ -128,7 +128,7 @@ public class TransportAggregationModule extends AbstractModule implements SpawnM AvgBucketPipelineAggregator.registerStreams(); SumBucketPipelineAggregator.registerStreams(); MovAvgPipelineAggregator.registerStreams(); - SeriesArithmeticPipelineAggregator.registerStreams(); + BucketScriptPipelineAggregator.registerStreams(); } @Override diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java index 18adc122cba..6a7181e82a9 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java @@ -23,9 +23,9 @@ import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucke import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketBuilder; import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketBuilder; import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptBuilder; import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeBuilder; import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgBuilder; -import org.elasticsearch.search.aggregations.pipeline.seriesarithmetic.SeriesArithmeticBuilder; public final class PipelineAggregatorBuilders { @@ -56,7 +56,7 @@ public final class PipelineAggregatorBuilders { return new MovAvgBuilder(name); } - public static final SeriesArithmeticBuilder seriesArithmetic(String name) { - return new SeriesArithmeticBuilder(name); + public static final BucketScriptBuilder seriesArithmetic(String name) { + return new BucketScriptBuilder(name); } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/seriesarithmetic/SeriesArithmeticBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptBuilder.java similarity index 74% rename from core/src/main/java/org/elasticsearch/search/aggregations/pipeline/seriesarithmetic/SeriesArithmeticBuilder.java rename to core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptBuilder.java index 7171b7c2b35..ee5fa94eede 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/seriesarithmetic/SeriesArithmeticBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptBuilder.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.pipeline.seriesarithmetic; +package org.elasticsearch.search.aggregations.pipeline.bucketscript; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.script.Script; @@ -29,28 +29,28 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder; import java.io.IOException; import java.util.Map; -public class SeriesArithmeticBuilder extends PipelineAggregatorBuilder { +public class BucketScriptBuilder extends PipelineAggregatorBuilder { private String format; private GapPolicy gapPolicy; private Script script; private Map bucketsPathsMap; - public SeriesArithmeticBuilder(String name) { - super(name, SeriesArithmeticPipelineAggregator.TYPE.name()); + public BucketScriptBuilder(String name) { + super(name, BucketScriptPipelineAggregator.TYPE.name()); } - public SeriesArithmeticBuilder script(Script script) { + public BucketScriptBuilder script(Script script) { this.script = script; return this; } - public SeriesArithmeticBuilder format(String format) { + public BucketScriptBuilder format(String format) { this.format = format; return this; } - public SeriesArithmeticBuilder gapPolicy(GapPolicy gapPolicy) { + public BucketScriptBuilder gapPolicy(GapPolicy gapPolicy) { this.gapPolicy = gapPolicy; return this; } @@ -58,7 +58,7 @@ public class SeriesArithmeticBuilder extends PipelineAggregatorBuilder bucketsPathsMap) { + public BucketScriptBuilder setBucketsPathsMap(Map bucketsPathsMap) { this.bucketsPathsMap = bucketsPathsMap; return this; } @@ -69,10 +69,10 @@ public class SeriesArithmeticBuilder extends PipelineAggregatorBuilder bucketsPathsMap; - public SeriesArithmeticPipelineAggregator() { + public BucketScriptPipelineAggregator() { } - public SeriesArithmeticPipelineAggregator(String name, Map bucketsPathsMap, Script script, @Nullable ValueFormatter formatter, + public BucketScriptPipelineAggregator(String name, Map bucketsPathsMap, Script script, @Nullable ValueFormatter formatter, GapPolicy gapPolicy, Map metadata) { super(name, bucketsPathsMap.values().toArray(new String[bucketsPathsMap.size()]), metadata); this.bucketsPathsMap = bucketsPathsMap; @@ -172,7 +172,7 @@ public class SeriesArithmeticPipelineAggregator extends PipelineAggregator { @Override protected PipelineAggregator createInternal(Map metaData) throws IOException { - return new SeriesArithmeticPipelineAggregator(name, bucketsPathsMap, script, formatter, gapPolicy, metaData); + return new BucketScriptPipelineAggregator(name, bucketsPathsMap, script, formatter, gapPolicy, metaData); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SeriesArithmeticTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java similarity index 99% rename from core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SeriesArithmeticTests.java rename to core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java index 2fbbb4d717a..7823b960415 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SeriesArithmeticTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java @@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @ElasticsearchIntegrationTest.SuiteScopeTest -public class SeriesArithmeticTests extends ElasticsearchIntegrationTest { +public class BucketScriptTests extends ElasticsearchIntegrationTest { private static final String FIELD_1_NAME = "field1"; private static final String FIELD_2_NAME = "field2"; diff --git a/docs/reference/aggregations/pipeline.asciidoc b/docs/reference/aggregations/pipeline.asciidoc index dbf63180144..def73fe28d9 100644 --- a/docs/reference/aggregations/pipeline.asciidoc +++ b/docs/reference/aggregations/pipeline.asciidoc @@ -160,4 +160,4 @@ include::pipeline/max-bucket-aggregation.asciidoc[] include::pipeline/min-bucket-aggregation.asciidoc[] include::pipeline/sum-bucket-aggregation.asciidoc[] include::pipeline/movavg-aggregation.asciidoc[] -include::pipeline/series-arithmetic-aggregation.asciidoc[] +include::pipeline/bucket-script-aggregation.asciidoc[] diff --git a/docs/reference/aggregations/pipeline/series-arithmetic-aggregation.asciidoc b/docs/reference/aggregations/pipeline/bucket-script-aggregation.asciidoc similarity index 95% rename from docs/reference/aggregations/pipeline/series-arithmetic-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/bucket-script-aggregation.asciidoc index dc39ab326d2..2bfac72256a 100644 --- a/docs/reference/aggregations/pipeline/series-arithmetic-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/bucket-script-aggregation.asciidoc @@ -1,17 +1,17 @@ -[[search-aggregations-pipeline-series-arithmetic-aggregation]] -=== Series Arithmetic Aggregation +[[search-aggregations-pipeline-bucket-script-aggregation]] +=== Bucket Script Aggregation A parent pipeline aggregation which executes a script which can perform per bucket computations on specified metrics in the parent multi-bucket aggregation. The specified metric must be numeric and the script must return a numeric value. ==== Syntax -A `series_arithmetic` aggregation looks like this in isolation: +A `bucket_script` aggregation looks like this in isolation: [source,js] -------------------------------------------------- { - "series_arithmetic": { + "bucket_script": { "buckets_path": { "my_var1": "the_sum", <1> "my_var2": "the_value_count" @@ -24,7 +24,7 @@ A `series_arithmetic` aggregation looks like this in isolation: the metrics to use for that variable. -.`series_arithmetic` Parameters +.`bucket_script` Parameters |=== |Parameter Name |Description |Required |Default Value |`script` |The script to run for this aggregation. The script can be inline, file or indexed. (see <>