Aggregation: Removed Old Script Java API from metrics aggregations
The old script syntax has been removed from the Java API but the metrics aggregations were missed. This change removes the old script API from the ValuesSourceMetricsAggregationBuilder and removes the relevant test methods for the metrics aggregations.
This commit is contained in:
parent
7db293c616
commit
bccfcfa522
|
@ -19,13 +19,10 @@
|
|||
|
||||
package org.elasticsearch.search.aggregations.metrics;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.script.Script;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -34,12 +31,6 @@ public abstract class ValuesSourceMetricsAggregationBuilder<B extends ValuesSour
|
|||
|
||||
private String field;
|
||||
private Script script;
|
||||
@Deprecated
|
||||
private String scriptString; // TODO Remove in 3.0
|
||||
@Deprecated
|
||||
private String lang; // TODO Remove in 3.0
|
||||
@Deprecated
|
||||
private Map<String, Object> params; // TODO Remove in 3.0
|
||||
private String format;
|
||||
private Object missing;
|
||||
|
||||
|
@ -62,53 +53,6 @@ public abstract class ValuesSourceMetricsAggregationBuilder<B extends ValuesSour
|
|||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #script(Script)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public B script(String script) {
|
||||
this.scriptString = script;
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #script(Script)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public B lang(String lang) {
|
||||
this.lang = lang;
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #script(Script)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public B params(Map<String, Object> params) {
|
||||
if (this.params == null) {
|
||||
this.params = params;
|
||||
} else {
|
||||
this.params.putAll(params);
|
||||
}
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #script(Script)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public B param(String name, Object value) {
|
||||
if (this.params == null) {
|
||||
this.params = Maps.newHashMap();
|
||||
}
|
||||
this.params.put(name, value);
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public B format(String format) {
|
||||
this.format = format;
|
||||
|
@ -133,22 +77,10 @@ public abstract class ValuesSourceMetricsAggregationBuilder<B extends ValuesSour
|
|||
builder.field("script", script);
|
||||
}
|
||||
|
||||
if (scriptString != null) {
|
||||
builder.field("script", scriptString);
|
||||
}
|
||||
|
||||
if (lang != null) {
|
||||
builder.field("lang", lang);
|
||||
}
|
||||
|
||||
if (format != null) {
|
||||
builder.field("format", format);
|
||||
}
|
||||
|
||||
if (this.params != null && !this.params.isEmpty()) {
|
||||
builder.field("params").map(this.params);
|
||||
}
|
||||
|
||||
if (missing != null) {
|
||||
builder.field("missing", missing);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.action.search.SearchType;
|
|||
import org.elasticsearch.action.update.UpdateRequestBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
|
||||
|
@ -362,8 +361,12 @@ public class ExpressionScriptTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
|
||||
req.setQuery(QueryBuilders.matchAllQuery())
|
||||
.addAggregation(AggregationBuilders.stats("int_agg").field("x").script("_value * 3").lang(ExpressionScriptEngineService.NAME))
|
||||
.addAggregation(AggregationBuilders.stats("double_agg").field("y").script("_value - 1.1").lang(ExpressionScriptEngineService.NAME));
|
||||
.addAggregation(
|
||||
AggregationBuilders.stats("int_agg").field("x")
|
||||
.script(new Script("_value * 3", ScriptType.INLINE, ExpressionScriptEngineService.NAME, null)))
|
||||
.addAggregation(
|
||||
AggregationBuilders.stats("double_agg").field("y")
|
||||
.script(new Script("_value - 1.1", ScriptType.INLINE, ExpressionScriptEngineService.NAME, null)));
|
||||
|
||||
SearchResponse rsp = req.get();
|
||||
assertEquals(3, rsp.getHits().getTotalHits());
|
||||
|
|
|
@ -474,21 +474,15 @@ public class TopHitsTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void testFieldCollapsing() throws Exception {
|
||||
SearchResponse response = client().prepareSearch("idx").setTypes("field-collapsing")
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.setTypes("field-collapsing")
|
||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||
.setQuery(matchQuery("text", "term rare"))
|
||||
.addAggregation(terms("terms")
|
||||
.executionHint(randomExecutionHint())
|
||||
.field("group")
|
||||
.order(Terms.Order.aggregation("max_score", false))
|
||||
.subAggregation(
|
||||
topHits("hits").setSize(1)
|
||||
)
|
||||
.subAggregation(
|
||||
max("max_score").script("_score.doubleValue()")
|
||||
)
|
||||
)
|
||||
.get();
|
||||
.addAggregation(
|
||||
terms("terms").executionHint(randomExecutionHint()).field("group")
|
||||
.order(Terms.Order.aggregation("max_score", false)).subAggregation(topHits("hits").setSize(1))
|
||||
.subAggregation(max("max_score").script(new Script("_score.doubleValue()")))).get();
|
||||
assertSearchResponse(response);
|
||||
|
||||
Terms terms = response.getAggregations().get("terms");
|
||||
|
|
|
@ -103,24 +103,4 @@ public abstract class AbstractNumericTests extends ElasticsearchIntegrationTest
|
|||
|
||||
public abstract void testScript_MultiValued_WithParams() throws Exception;
|
||||
|
||||
public abstract void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testScript_SingleValued_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testScript_MultiValued_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception;
|
||||
|
||||
public abstract void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception;
|
||||
|
||||
}
|
|
@ -335,194 +335,4 @@ public class AvgTests extends AbstractNumericTests {
|
|||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (1+2+2+3+3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11) / 20));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").field("value").script("_value + 1"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").field("value").script("_value + inc").param("inc", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").field("values").script("_value + 1"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11+11+12+12+13) / 20));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").field("values").script("_value + inc").param("inc", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11+11+12+12+13) / 20));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").script("doc['value'].value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").script("doc['value'].value + inc").param("inc", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").script("doc['value'].value + inc").param("inc", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").script("[ doc['value'].value, doc['value'].value + 1 ]"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (1+2+2+3+3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11) / 20));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").script("[ doc['value'].value, doc['value'].value + 1 ]"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (1+2+2+3+3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11) / 20));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(avg("avg").script("[ doc['value'].value, doc['value'].value + inc ]").param("inc", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Avg avg = searchResponse.getAggregations().get("avg");
|
||||
assertThat(avg, notNullValue());
|
||||
assertThat(avg.getName(), equalTo("avg"));
|
||||
assertThat(avg.getValue(), equalTo((double) (1+2+2+3+3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11) / 20));
|
||||
}
|
||||
}
|
|
@ -483,152 +483,4 @@ public class CardinalityTests extends ElasticsearchIntegrationTest {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void singleValuedStringScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
||||
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script("doc['str_value'].value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void multiValuedStringScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
||||
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script("doc['str_values'].values"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs * 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void singleValuedNumericScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.setTypes("type")
|
||||
.addAggregation(
|
||||
cardinality("cardinality").precisionThreshold(precisionThreshold).script(
|
||||
"doc['" + singleNumericField(false) + "'].value")).execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void multiValuedNumericScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.setTypes("type")
|
||||
.addAggregation(
|
||||
cardinality("cardinality").precisionThreshold(precisionThreshold).script(
|
||||
"doc['" + multiNumericField(false) + "'].values")).execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs * 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void singleValuedStringValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
||||
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value").script("_value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void multiValuedStringValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
||||
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_values").script("_value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs * 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void singleValuedNumericValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.setTypes("type")
|
||||
.addAggregation(
|
||||
cardinality("cardinality").precisionThreshold(precisionThreshold).field(singleNumericField(false)).script("_value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void multiValuedNumericValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("idx")
|
||||
.setTypes("type")
|
||||
.addAggregation(
|
||||
cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(false)).script("_value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
||||
Cardinality count = response.getAggregations().get("cardinality");
|
||||
assertThat(count, notNullValue());
|
||||
assertThat(count.getName(), equalTo("cardinality"));
|
||||
assertCount(count, numDocs * 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -578,283 +578,4 @@ public class ExtendedStatsTests extends AbstractNumericTests {
|
|||
assertThat(stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER), equalTo(stats.getAvg() - (stats.getStdDeviation() * sigma)));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").field("value").script("_value + 1").sigma(sigma)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 121));
|
||||
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").field("value").script("_value + inc").param("inc", 1).sigma(sigma)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 121));
|
||||
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").field("values").script("_value - 1").sigma(sigma)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 20));
|
||||
assertThat(stats.getMin(), equalTo(1.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 4 + 9 + 16 + 25 + 36 + 49 + 64
|
||||
+ 81 + 100 + 121));
|
||||
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").field("values").script("_value - dec").param("dec", 1).sigma(sigma)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 20));
|
||||
assertThat(stats.getMin(), equalTo(1.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 4 + 9 + 16 + 25 + 36 + 49 + 64
|
||||
+ 81 + 100 + 121));
|
||||
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").script("doc['value'].value").sigma(sigma)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) / 10));
|
||||
assertThat(stats.getMin(), equalTo(1.0));
|
||||
assertThat(stats.getMax(), equalTo(10.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100));
|
||||
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").script("doc['value'].value + inc").param("inc", 1).sigma(sigma)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 121));
|
||||
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").script("doc['value'].value + inc").param("inc", 1).sigma(sigma)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 121));
|
||||
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").script("doc['values'].values").sigma(sigma)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12) / 20));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(12.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 121 + 9 + 16 + 25 + 36 + 49 + 64
|
||||
+ 81 + 100 + 121 + 144));
|
||||
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(extendedStats("stats").script("doc['values'].values").sigma(sigma)).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12) / 20));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(12.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 121 + 9 + 16 + 25 + 36 + 49 + 64
|
||||
+ 81 + 100 + 121 + 144));
|
||||
assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
double sigma = randomDouble() * randomIntBetween(1, 10);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
extendedStats("stats").script("[ doc['value'].value, doc['value'].value - dec ]").param("dec", 1).sigma(sigma))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ExtendedStats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) / 20));
|
||||
assertThat(stats.getMin(), equalTo(0.0));
|
||||
assertThat(stats.getMax(), equalTo(10.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
assertThat(stats.getSumOfSquares(), equalTo((double) 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 + 0 + 1 + 4 + 9 + 16 + 25 + 36
|
||||
+ 49 + 64 + 81));
|
||||
assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)));
|
||||
assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)));
|
||||
checkUpperLowerBounds(stats, sigma);
|
||||
}
|
||||
|
||||
}
|
|
@ -335,177 +335,4 @@ public class MaxTests extends AbstractNumericTests {
|
|||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(11.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").field("value").script("_value + 1")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(11.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").field("value").script("_value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(11.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").field("values").script("_value + 1")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(13.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").field("values").script("_value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(13.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").script("doc['value'].value")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(10.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").script("doc['value'].value + inc").param("inc", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(11.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").script("doc['value'].value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(11.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").script("doc['values'].values")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(12.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").script("doc['values'].values")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(12.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(max("max").script("[ doc['value'].value, doc['value'].value + inc ]").param("inc", 1)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Max max = searchResponse.getAggregations().get("max");
|
||||
assertThat(max, notNullValue());
|
||||
assertThat(max.getName(), equalTo("max"));
|
||||
assertThat(max.getValue(), equalTo(11.0));
|
||||
}
|
||||
}
|
|
@ -345,208 +345,4 @@ public class MinTests extends AbstractNumericTests {
|
|||
assertThat(min.getValue(), equalTo(1.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").field("value").script("_value - 1")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(0.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").field("value").script("_value - dec").param("dec", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(0.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").field("values").script("_value - 1"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(1.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_Reverse_OldScriptAPI() throws Exception {
|
||||
// test what happens when values arrive in reverse order since the min aggregator is optimized to work on sorted values
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").field("values").script("_value * -1"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(-12d));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").field("values").script("_value - dec").param("dec", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(1.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").script("doc['value'].value"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(1.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").script("doc['value'].value - dec").param("dec", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(0.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").script("doc['value'].value - dec").param("dec", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(0.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").script("doc['values'].values"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(2.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").script("doc['values'].values"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(2.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(min("min").script("List values = doc['values'].values; double[] res = new double[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = values.get(i) - dec; }; return res;").param("dec", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Min min = searchResponse.getAggregations().get("min");
|
||||
assertThat(min, notNullValue());
|
||||
assertThat(min.getName(), equalTo("min"));
|
||||
assertThat(min.getValue(), equalTo(1.0));
|
||||
}
|
||||
|
||||
}
|
|
@ -472,215 +472,4 @@ public class PercentileRanksTests extends AbstractNumericTests {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).field("value").script("_value - 1").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).field("value").script("_value - dec").param("dec", 1)
|
||||
.percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).field("values").script("_value - 1").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_Reverse_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(-maxValues, -minValues);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).field("values").script("_value * -1").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, -maxValues, -minValues);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).field("values").script("_value - dec").param("dec", 1)
|
||||
.percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValue, maxValue);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentileRanks("percentile_ranks")).script("doc['value'].value").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValue, maxValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).script("doc['value'].value - dec").param("dec", 1)
|
||||
.percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks")).script("doc['value'].value - dec").param("dec", 1)
|
||||
.percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValues, maxValues);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentileRanks("percentile_ranks")).script("doc['values'].values").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValues, maxValues);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValues, maxValues);
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentileRanks("percentile_ranks")).script("doc['values'].values").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValues, maxValues);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentileRanks("percentile_ranks"))
|
||||
.script("List values = doc['values'].values; double[] res = new double[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = values.get(i) - dec; }; return res;")
|
||||
.param("dec", 1).percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final PercentileRanks percentiles = searchResponse.getAggregations().get("percentile_ranks");
|
||||
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -455,206 +455,4 @@ public class PercentilesTests extends AbstractNumericTests {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentiles("percentiles")).field("value").script("_value - 1").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentiles("percentiles")).field("value").script("_value - dec").param("dec", 1)
|
||||
.percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentiles("percentiles")).field("values").script("_value - 1").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_Reverse_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentiles("percentiles")).field("values").script("_value * -1").percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, -maxValues, -minValues);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentiles("percentiles")).field("values").script("_value - dec").param("dec", 1)
|
||||
.percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentiles("percentiles")).script("doc['value'].value").percentiles(pcts)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValue, maxValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentiles("percentiles")).script("doc['value'].value - dec").param("dec", 1).percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentiles("percentiles")).script("doc['value'].value - dec").param("dec", 1).percentiles(pcts))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValue - 1, maxValue - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentiles("percentiles")).script("doc['values'].values").percentiles(pcts)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValues, maxValues);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(randomCompression(percentiles("percentiles")).script("doc['values'].values").percentiles(pcts)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValues, maxValues);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
final double[] pcts = randomPercentiles();
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(
|
||||
randomCompression(percentiles("percentiles"))
|
||||
.script("List values = doc['values'].values; double[] res = new double[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = values.get(i) - dec; }; return res;")
|
||||
.param("dec", 1).percentiles(pcts)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
final Percentiles percentiles = searchResponse.getAggregations().get("percentiles");
|
||||
assertConsistent(pcts, percentiles, minValues - 1, maxValues - 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -463,239 +463,4 @@ public class StatsTests extends AbstractNumericTests {
|
|||
}
|
||||
assertThat("Not all shards are initialized", response.getSuccessfulShards(), equalTo(response.getTotalShards()));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").field("value").script("_value + 1")).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").field("value").script("_value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").field("values").script("_value - 1")).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 20));
|
||||
assertThat(stats.getMin(), equalTo(1.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").field("values").script("_value - dec").param("dec", 1)).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 20));
|
||||
assertThat(stats.getMin(), equalTo(1.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").script("doc['value'].value")).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) / 10));
|
||||
assertThat(stats.getMin(), equalTo(1.0));
|
||||
assertThat(stats.getMax(), equalTo(10.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").script("doc['value'].value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").script("doc['value'].value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11) / 10));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(11.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
assertThat(stats.getCount(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").script("doc['values'].values")).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12) / 20));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(12.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").script("doc['values'].values")).execute().actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(),
|
||||
equalTo((double) (2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12) / 20));
|
||||
assertThat(stats.getMin(), equalTo(2.0));
|
||||
assertThat(stats.getMax(), equalTo(12.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(stats("stats").script("[ doc['value'].value, doc['value'].value - dec ]").param("dec", 1)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertShardExecutionState(searchResponse, 0);
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Stats stats = searchResponse.getAggregations().get("stats");
|
||||
assertThat(stats, notNullValue());
|
||||
assertThat(stats.getName(), equalTo("stats"));
|
||||
assertThat(stats.getAvg(), equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) / 20));
|
||||
assertThat(stats.getMin(), equalTo(0.0));
|
||||
assertThat(stats.getMax(), equalTo(10.0));
|
||||
assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9));
|
||||
assertThat(stats.getCount(), equalTo(20l));
|
||||
}
|
||||
}
|
|
@ -336,168 +336,4 @@ public class SumTests extends AbstractNumericTests {
|
|||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 + 7 + 8 + 8 + 9 + 9 + 10 + 10 + 11 + 11 + 12 + 12 + 13));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").field("value").script("_value + 1")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testSingleValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").field("value").script("_value + increment").param("increment", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").script("doc['value'].value")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_SingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").script("doc['value'].value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitSingleValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").script("doc['value'].value + inc").param("inc", 1)).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").script("[ doc['value'].value, doc['value'].value + 1 ]")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 + 7 + 8 + 8 + 9 + 9 + 10 + 10 + 11));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_ExplicitMultiValued_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").script("[ doc['value'].value, doc['value'].value + 1 ]")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 + 7 + 8 + 8 + 9 + 9 + 10 + 10 + 11));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testScript_MultiValued_WithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").script("[ doc['value'].value, doc['value'].value + inc ]").param("inc", 1)).execute()
|
||||
.actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 + 7 + 8 + 8 + 9 + 9 + 10 + 10 + 11));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_OldScriptAPI() throws Exception {
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").field("values").script("_value + 1"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11+11+12+12+13));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testMultiValuedField_WithValueScript_WithParams_OldScriptAPI() throws Exception {
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("idx")
|
||||
.setQuery(matchAllQuery())
|
||||
.addAggregation(sum("sum").field("values").script("_value + increment").param("increment", 1))
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
Sum sum = searchResponse.getAggregations().get("sum");
|
||||
assertThat(sum, notNullValue());
|
||||
assertThat(sum.getName(), equalTo("sum"));
|
||||
assertThat(sum.getValue(), equalTo((double) 3+4+4+5+5+6+6+7+7+8+8+9+9+10+10+11+11+12+12+13));
|
||||
}
|
||||
}
|
|
@ -201,68 +201,4 @@ public class ValueCountTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(valueCount.getValue(), equalTo(20l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void singleValuedScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(count("count").script("doc['value'].value")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ValueCount valueCount = searchResponse.getAggregations().get("count");
|
||||
assertThat(valueCount, notNullValue());
|
||||
assertThat(valueCount.getName(), equalTo("count"));
|
||||
assertThat(valueCount.getValue(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void multiValuedScript_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(count("count").script("doc['values'].values")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ValueCount valueCount = searchResponse.getAggregations().get("count");
|
||||
assertThat(valueCount, notNullValue());
|
||||
assertThat(valueCount.getName(), equalTo("count"));
|
||||
assertThat(valueCount.getValue(), equalTo(20l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void singleValuedScriptWithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(count("count").script("doc[s].value").param("s", "value")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ValueCount valueCount = searchResponse.getAggregations().get("count");
|
||||
assertThat(valueCount, notNullValue());
|
||||
assertThat(valueCount.getName(), equalTo("count"));
|
||||
assertThat(valueCount.getValue(), equalTo(10l));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Remove in 3.0
|
||||
*/
|
||||
@Test
|
||||
public void multiValuedScriptWithParams_OldScriptAPI() throws Exception {
|
||||
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
|
||||
.addAggregation(count("count").script("doc[s].values").param("s", "values")).execute().actionGet();
|
||||
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l));
|
||||
|
||||
ValueCount valueCount = searchResponse.getAggregations().get("count");
|
||||
assertThat(valueCount, notNullValue());
|
||||
assertThat(valueCount.getName(), equalTo("count"));
|
||||
assertThat(valueCount.getValue(), equalTo(20l));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue