Aggregations: Rename `series_arithmetic` agg to `bucket_script`

This commit is contained in:
Colin Goodheart-Smithe 2015-06-17 10:48:21 +01:00
parent 79f3e78ce2
commit f26311e88b
9 changed files with 36 additions and 36 deletions

View File

@ -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);
}
/**

View File

@ -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

View File

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

View File

@ -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<SeriesArithmeticBuilder> {
public class BucketScriptBuilder extends PipelineAggregatorBuilder<BucketScriptBuilder> {
private String format;
private GapPolicy gapPolicy;
private Script script;
private Map<String, String> 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<SeriesAri
/**
* Sets the paths to the buckets to use for this pipeline aggregator
*/
public SeriesArithmeticBuilder setBucketsPathsMap(Map<String, String> bucketsPathsMap) {
public BucketScriptBuilder setBucketsPathsMap(Map<String, String> bucketsPathsMap) {
this.bucketsPathsMap = bucketsPathsMap;
return this;
}
@ -69,10 +69,10 @@ public class SeriesArithmeticBuilder extends PipelineAggregatorBuilder<SeriesAri
builder.field(ScriptField.SCRIPT.getPreferredName(), script);
}
if (format != null) {
builder.field(SeriesArithmeticParser.FORMAT.getPreferredName(), format);
builder.field(BucketScriptParser.FORMAT.getPreferredName(), format);
}
if (gapPolicy != null) {
builder.field(SeriesArithmeticParser.GAP_POLICY.getPreferredName(), gapPolicy.getName());
builder.field(BucketScriptParser.GAP_POLICY.getPreferredName(), gapPolicy.getName());
}
if (bucketsPathsMap != null) {
builder.field(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName(), bucketsPathsMap);

View File

@ -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.ParseField;
import org.elasticsearch.common.xcontent.XContentParser;
@ -37,7 +37,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SeriesArithmeticParser implements PipelineAggregator.Parser {
public class BucketScriptParser implements PipelineAggregator.Parser {
public static final ParseField FORMAT = new ParseField("format");
public static final ParseField GAP_POLICY = new ParseField("gap_policy");
@ -45,7 +45,7 @@ public class SeriesArithmeticParser implements PipelineAggregator.Parser {
@Override
public String type() {
return SeriesArithmeticPipelineAggregator.TYPE.name();
return BucketScriptPipelineAggregator.TYPE.name();
}
@Override
@ -123,7 +123,7 @@ public class SeriesArithmeticParser implements PipelineAggregator.Parser {
formatter = ValueFormat.Patternable.Number.format(format).formatter();
}
return new SeriesArithmeticPipelineAggregator.Factory(reducerName, bucketsPathsMap, script, formatter, gapPolicy);
return new BucketScriptPipelineAggregator.Factory(reducerName, bucketsPathsMap, script, formatter, gapPolicy);
}
}

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.search.aggregations.pipeline.seriesarithmetic;
package org.elasticsearch.search.aggregations.pipeline.bucketscript;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
@ -53,14 +53,14 @@ import java.util.Map;
import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue;
public class SeriesArithmeticPipelineAggregator extends PipelineAggregator {
public class BucketScriptPipelineAggregator extends PipelineAggregator {
public final static Type TYPE = new Type("series_arithmetic");
public final static Type TYPE = new Type("bucket_script");
public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() {
@Override
public SeriesArithmeticPipelineAggregator readResult(StreamInput in) throws IOException {
SeriesArithmeticPipelineAggregator result = new SeriesArithmeticPipelineAggregator();
public BucketScriptPipelineAggregator readResult(StreamInput in) throws IOException {
BucketScriptPipelineAggregator result = new BucketScriptPipelineAggregator();
result.readFrom(in);
return result;
}
@ -84,10 +84,10 @@ public class SeriesArithmeticPipelineAggregator extends PipelineAggregator {
private Map<String, String> bucketsPathsMap;
public SeriesArithmeticPipelineAggregator() {
public BucketScriptPipelineAggregator() {
}
public SeriesArithmeticPipelineAggregator(String name, Map<String, String> bucketsPathsMap, Script script, @Nullable ValueFormatter formatter,
public BucketScriptPipelineAggregator(String name, Map<String, String> bucketsPathsMap, Script script, @Nullable ValueFormatter formatter,
GapPolicy gapPolicy, Map<String, Object> 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<String, Object> metaData) throws IOException {
return new SeriesArithmeticPipelineAggregator(name, bucketsPathsMap, script, formatter, gapPolicy, metaData);
return new BucketScriptPipelineAggregator(name, bucketsPathsMap, script, formatter, gapPolicy, metaData);
}
}

View File

@ -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";

View File

@ -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[]

View File

@ -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 <<modules-scripting>>