mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
parent
8a1db8c6c3
commit
1eda6ac74b
263 changed files with 4724 additions and 6555 deletions
|
@ -565,30 +565,22 @@ public class MoreExpressionIT extends ESIntegTestCase {
|
|||
client().prepareIndex("agg_index").setId("4").setSource("one", 4.0, "two", 2.0, "three", 3.0, "four", 4.0),
|
||||
client().prepareIndex("agg_index").setId("5").setSource("one", 5.0, "two", 2.0, "three", 3.0, "four", 4.0)
|
||||
);
|
||||
SearchResponse response = client().prepareSearch("agg_index")
|
||||
.addAggregation(
|
||||
histogram("histogram").field("one")
|
||||
.interval(2)
|
||||
.subAggregation(sum("twoSum").field("two"))
|
||||
.subAggregation(sum("threeSum").field("three"))
|
||||
.subAggregation(sum("fourSum").field("four"))
|
||||
.subAggregation(
|
||||
bucketScript(
|
||||
"totalSum",
|
||||
new Script(
|
||||
ScriptType.INLINE,
|
||||
ExpressionScriptEngine.NAME,
|
||||
"_value0 + _value1 + _value2",
|
||||
Collections.emptyMap()
|
||||
),
|
||||
"twoSum",
|
||||
"threeSum",
|
||||
"fourSum"
|
||||
)
|
||||
SearchResponse response = prepareSearch("agg_index").addAggregation(
|
||||
histogram("histogram").field("one")
|
||||
.interval(2)
|
||||
.subAggregation(sum("twoSum").field("two"))
|
||||
.subAggregation(sum("threeSum").field("three"))
|
||||
.subAggregation(sum("fourSum").field("four"))
|
||||
.subAggregation(
|
||||
bucketScript(
|
||||
"totalSum",
|
||||
new Script(ScriptType.INLINE, ExpressionScriptEngine.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
|
||||
"twoSum",
|
||||
"threeSum",
|
||||
"fourSum"
|
||||
)
|
||||
)
|
||||
.execute()
|
||||
.actionGet();
|
||||
)
|
||||
).execute().actionGet();
|
||||
|
||||
Histogram histogram = response.getAggregations().get("histogram");
|
||||
assertThat(histogram, notNullValue());
|
||||
|
|
|
@ -61,13 +61,11 @@ public class StoredExpressionIT extends ESIntegTestCase {
|
|||
assertThat(e.toString(), containsString("cannot execute scripts using [field] context"));
|
||||
}
|
||||
try {
|
||||
client().prepareSearch("test")
|
||||
.setSource(
|
||||
new SearchSourceBuilder().aggregation(
|
||||
AggregationBuilders.terms("test").script(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap()))
|
||||
)
|
||||
prepareSearch("test").setSource(
|
||||
new SearchSourceBuilder().aggregation(
|
||||
AggregationBuilders.terms("test").script(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap()))
|
||||
)
|
||||
.get();
|
||||
).get();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.toString(), containsString("cannot execute scripts using [aggs] context"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue