summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/search
diff options
context:
space:
mode:
authorJack Conradson <osjdconrad@gmail.com>2016-11-10 09:59:13 -0800
committerJack Conradson <osjdconrad@gmail.com>2016-11-10 09:59:13 -0800
commitaeb97ff41298e26b107a733837dfe17f123c0c9b (patch)
tree8d37fa8c7365df2ce52626b003c1838572a62d88 /core/src/test/java/org/elasticsearch/search
parent2e531902ffb776e6ea9d15e99ab904aa4cb256dc (diff)
Clean up of Script.
Closes #21321
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search')
-rw-r--r--core/src/test/java/org/elasticsearch/search/SearchCancellationIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/AggregationTestScriptsPlugin.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsIT.java25
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/IpRangeIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java22
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java24
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/MinIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricIT.java117
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java24
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java18
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptIT.java28
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorIT.java36
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/fetch/subphase/InnerHitsIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java43
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/search/geo/GeoDistanceIT.java19
-rw-r--r--core/src/test/java/org/elasticsearch/search/scriptfilter/ScriptQuerySearchIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/search/sort/SimpleSortIT.java17
-rw-r--r--core/src/test/java/org/elasticsearch/search/stats/SearchStatsIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilderTests.java2
45 files changed, 407 insertions, 317 deletions
diff --git a/core/src/test/java/org/elasticsearch/search/SearchCancellationIT.java b/core/src/test/java/org/elasticsearch/search/SearchCancellationIT.java
index 53653392e6..d615e95499 100644
--- a/core/src/test/java/org/elasticsearch/search/SearchCancellationIT.java
+++ b/core/src/test/java/org/elasticsearch/search/SearchCancellationIT.java
@@ -147,7 +147,8 @@ public class SearchCancellationIT extends ESIntegTestCase {
logger.info("Executing search");
ListenableActionFuture<SearchResponse> searchResponse = client().prepareSearch("test").setQuery(
- scriptQuery(new Script(NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, ScriptType.INLINE, "native", null)))
+ scriptQuery(new Script(
+ ScriptType.INLINE, "native", NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, Collections.emptyMap())))
.execute();
awaitForBlock(plugins);
@@ -165,7 +166,7 @@ public class SearchCancellationIT extends ESIntegTestCase {
logger.info("Executing search");
ListenableActionFuture<SearchResponse> searchResponse = client().prepareSearch("test")
.addScriptField("test_field",
- new Script(NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, ScriptType.INLINE, "native", null)
+ new Script(ScriptType.INLINE, "native", NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, Collections.emptyMap())
).execute();
awaitForBlock(plugins);
@@ -186,7 +187,8 @@ public class SearchCancellationIT extends ESIntegTestCase {
.setScroll(TimeValue.timeValueSeconds(10))
.setSize(5)
.setQuery(
- scriptQuery(new Script(NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, ScriptType.INLINE, "native", null)))
+ scriptQuery(new Script(
+ ScriptType.INLINE, "native", NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, Collections.emptyMap())))
.execute();
awaitForBlock(plugins);
@@ -211,7 +213,8 @@ public class SearchCancellationIT extends ESIntegTestCase {
.setScroll(keepAlive)
.setSize(2)
.setQuery(
- scriptQuery(new Script(NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, ScriptType.INLINE, "native", null)))
+ scriptQuery(new Script(
+ ScriptType.INLINE, "native", NativeTestScriptedBlockFactory.TEST_NATIVE_BLOCK_SCRIPT, Collections.emptyMap())))
.get();
assertNotNull(searchResponse.getScrollId());
diff --git a/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java b/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java
index be133c37b3..6a6838a9c4 100644
--- a/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java
+++ b/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java
@@ -58,7 +58,8 @@ public class SearchTimeoutIT extends ESIntegTestCase {
client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
SearchResponse searchResponse = client().prepareSearch("test").setTimeout(new TimeValue(10, TimeUnit.MILLISECONDS))
- .setQuery(scriptQuery(new Script(NativeTestScriptedTimeout.TEST_NATIVE_SCRIPT_TIMEOUT, ScriptType.INLINE, "native", null)))
+ .setQuery(scriptQuery(
+ new Script(ScriptType.INLINE, "native", NativeTestScriptedTimeout.TEST_NATIVE_SCRIPT_TIMEOUT, Collections.emptyMap())))
.execute().actionGet();
assertThat(searchResponse.isTimedOut(), equalTo(true));
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationTestScriptsPlugin.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationTestScriptsPlugin.java
index b9a921c766..bc98dda41d 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationTestScriptsPlugin.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationTestScriptsPlugin.java
@@ -44,7 +44,7 @@ public class AggregationTestScriptsPlugin extends MockScriptPlugin {
// res[i] = values.get(i) - dec;
// };
// return res;
- public static final Script DECREMENT_ALL_VALUES = new Script("decrement all values", ScriptType.INLINE, NAME, singletonMap("dec", 1));
+ public static final Script DECREMENT_ALL_VALUES = new Script(ScriptType.INLINE, NAME, "decrement all values", singletonMap("dec", 1));
@Override
protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
@@ -91,7 +91,7 @@ public class AggregationTestScriptsPlugin extends MockScriptPlugin {
return doc.get("values");
});
- scripts.put(DECREMENT_ALL_VALUES.getScript(), vars -> {
+ scripts.put(DECREMENT_ALL_VALUES.getIdOrCode(), vars -> {
int dec = (int) vars.get("dec");
Map<?, ?> doc = (Map) vars.get("doc");
ScriptDocValues.Longs values = (ScriptDocValues.Longs) doc.get("values");
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java
index 4e1d8b6648..00f82dfbe4 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java
@@ -383,7 +383,7 @@ public class EquivalenceIT extends ESIntegTestCase {
terms("terms")
.field("values")
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("floor(_value / interval)", ScriptType.INLINE, CustomScriptPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "floor(_value / interval)", params))
.size(maxNumTerms))
.addAggregation(
histogram("histo")
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java
index bca3eb9c9d..90342df179 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java
@@ -496,7 +496,7 @@ public class DateHistogramIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("date")
- .script(new Script(DateScriptMocks.PlusOneMonthScript.NAME, ScriptType.INLINE, "native", params))
+ .script(new Script(ScriptType.INLINE, "native", DateScriptMocks.PlusOneMonthScript.NAME, params))
.dateHistogramInterval(DateHistogramInterval.MONTH)).execute().actionGet();
assertSearchResponse(response);
@@ -632,7 +632,7 @@ public class DateHistogramIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateHistogram("histo")
.field("dates")
- .script(new Script(DateScriptMocks.PlusOneMonthScript.NAME, ScriptType.INLINE, "native", params))
+ .script(new Script(ScriptType.INLINE, "native", DateScriptMocks.PlusOneMonthScript.NAME, params))
.dateHistogramInterval(DateHistogramInterval.MONTH)).execute().actionGet();
assertSearchResponse(response);
@@ -684,8 +684,8 @@ public class DateHistogramIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("fieldname", "date");
SearchResponse response = client().prepareSearch("idx")
- .addAggregation(dateHistogram("histo").script(new Script(DateScriptMocks.ExtractFieldScript.NAME,
- ScriptType.INLINE, "native", params)).dateHistogramInterval(DateHistogramInterval.MONTH))
+ .addAggregation(dateHistogram("histo").script(new Script(ScriptType.INLINE, "native", DateScriptMocks.ExtractFieldScript.NAME,
+ params)).dateHistogramInterval(DateHistogramInterval.MONTH))
.execute().actionGet();
assertSearchResponse(response);
@@ -722,8 +722,8 @@ public class DateHistogramIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("fieldname", "dates");
SearchResponse response = client().prepareSearch("idx")
- .addAggregation(dateHistogram("histo").script(new Script(DateScriptMocks.ExtractFieldScript.NAME,
- ScriptType.INLINE, "native", params)).dateHistogramInterval(DateHistogramInterval.MONTH))
+ .addAggregation(dateHistogram("histo").script(new Script(ScriptType.INLINE, "native", DateScriptMocks.ExtractFieldScript.NAME,
+ params)).dateHistogramInterval(DateHistogramInterval.MONTH))
.execute().actionGet();
assertSearchResponse(response);
@@ -1214,7 +1214,7 @@ public class DateHistogramIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("fieldname", "d");
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(dateHistogram("histo").field("d")
- .script(new Script(DateScriptMocks.PlusOneMonthScript.NAME, ScriptType.INLINE, "native", params))
+ .script(new Script(ScriptType.INLINE, "native", DateScriptMocks.PlusOneMonthScript.NAME, params))
.dateHistogramInterval(DateHistogramInterval.MONTH)).get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeIT.java
index 5fe0880868..71d97d3969 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeIT.java
@@ -119,7 +119,7 @@ public class DateRangeIT extends ESIntegTestCase {
if (randomBoolean()) {
rangeBuilder.field("date");
} else {
- rangeBuilder.script(new Script(DateScriptMocks.ExtractFieldScript.NAME, ScriptType.INLINE, "native", params));
+ rangeBuilder.script(new Script(ScriptType.INLINE, "native", DateScriptMocks.ExtractFieldScript.NAME, params));
}
SearchResponse response = client()
.prepareSearch("idx")
@@ -541,7 +541,7 @@ public class DateRangeIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
.field("dates")
- .script(new Script(DateScriptMocks.PlusOneMonthScript.NAME, ScriptType.INLINE, "native", params))
+ .script(new Script(ScriptType.INLINE, "native", DateScriptMocks.PlusOneMonthScript.NAME, params))
.addUnboundedTo(date(2, 15)).addRange(date(2, 15), date(3, 15)).addUnboundedFrom(date(3, 15))).execute()
.actionGet();
@@ -597,7 +597,7 @@ public class DateRangeIT extends ESIntegTestCase {
params.put("fieldname", "date");
SearchResponse response = client().prepareSearch("idx")
.addAggregation(dateRange("range")
- .script(new Script(DateScriptMocks.ExtractFieldScript.NAME, ScriptType.INLINE, "native", params))
+ .script(new Script(ScriptType.INLINE, "native", DateScriptMocks.ExtractFieldScript.NAME, params))
.addUnboundedTo(date(2, 15))
.addRange(date(2, 15), date(3, 15))
.addUnboundedFrom(date(3, 15)))
@@ -659,7 +659,7 @@ public class DateRangeIT extends ESIntegTestCase {
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
- dateRange("range").script(new Script(DateScriptMocks.ExtractFieldScript.NAME, ScriptType.INLINE, "native", params))
+ dateRange("range").script(new Script(ScriptType.INLINE, "native", DateScriptMocks.ExtractFieldScript.NAME, params))
.addUnboundedTo(date(2, 15)).addRange(date(2, 15), date(3, 15))
.addUnboundedFrom(date(3, 15))).execute().actionGet();
@@ -889,7 +889,7 @@ public class DateRangeIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("fieldname", "date");
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(dateRange("foo").field("date")
- .script(new Script(DateScriptMocks.PlusOneMonthScript.NAME, ScriptType.INLINE, "native", params))
+ .script(new Script(ScriptType.INLINE, "native", DateScriptMocks.PlusOneMonthScript.NAME, params))
.addRange(new DateTime(2012, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC), new DateTime(2013, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC)))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsIT.java
index e92485e642..1dc9943e8a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsIT.java
@@ -452,7 +452,7 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -505,7 +505,7 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -534,7 +534,8 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("(long) (_value / 1000 + 1)", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "(long) (_value / 1000 + 1)", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -576,8 +577,8 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
.addAggregation(
terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "'].value", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "doc['" + MULTI_VALUED_FIELD_NAME + "'].value", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -603,8 +604,8 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
.addAggregation(
terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + MULTI_VALUED_FIELD_NAME + "']",
+ Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -1078,10 +1079,11 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
}
public void testScriptScore() {
- Script scoringScript =
- new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", ScriptType.INLINE, CustomScriptPlugin .NAME, null);
+ Script scoringScript = new Script(
+ ScriptType.INLINE, CustomScriptPlugin .NAME, "doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", Collections.emptyMap());
- Script aggregationScript = new Script("ceil(_score.doubleValue()/3)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script aggregationScript = new Script(
+ ScriptType.INLINE, CustomScriptPlugin.NAME, "ceil(_score.doubleValue()/3)", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -1200,7 +1202,8 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(
- terms("terms").field("d").script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null))).get();
+ terms("terms").field("d").script(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java
index 7e7815de54..e25aeae29f 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java
@@ -562,7 +562,7 @@ public class HistogramIT extends ESIntegTestCase {
.addAggregation(
histogram("histo")
.field(SINGLE_VALUED_FIELD_NAME)
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", emptyMap()))
.interval(interval))
.execute().actionGet();
@@ -639,7 +639,7 @@ public class HistogramIT extends ESIntegTestCase {
.addAggregation(
histogram("histo")
.field(MULTI_VALUED_FIELD_NAME)
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", emptyMap()))
.interval(interval))
.execute().actionGet();
@@ -675,7 +675,7 @@ public class HistogramIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
histogram("histo")
- .script(new Script("doc['l_value'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['l_value'].value", emptyMap()))
.interval(interval))
.execute().actionGet();
@@ -699,7 +699,7 @@ public class HistogramIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
histogram("histo")
- .script(new Script("doc['l_values']", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['l_values']", emptyMap()))
.interval(interval))
.execute().actionGet();
@@ -1016,7 +1016,7 @@ public class HistogramIT extends ESIntegTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(histogram("histo").field("d")
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())).interval(0.7).offset(0.05)).get();
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", emptyMap())).interval(0.7).offset(0.05)).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/IpRangeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/IpRangeIT.java
index 7e7b11c859..cc4818963a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/IpRangeIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/IpRangeIT.java
@@ -208,7 +208,7 @@ public class IpRangeIT extends ESIntegTestCase {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> client().prepareSearch("idx").addAggregation(
AggregationBuilders.ipRange("my_range")
- .script(new Script(DummyScript.NAME, ScriptType.INLINE, "native", Collections.emptyMap())) ).get());
+ .script(new Script(ScriptType.INLINE, "native", DummyScript.NAME, Collections.emptyMap())) ).get());
assertThat(e.getMessage(), containsString("[ip_range] does not support scripts"));
}
@@ -217,7 +217,7 @@ public class IpRangeIT extends ESIntegTestCase {
() -> client().prepareSearch("idx").addAggregation(
AggregationBuilders.ipRange("my_range")
.field("ip")
- .script(new Script(DummyScript.NAME, ScriptType.INLINE, "native", Collections.emptyMap())) ).get());
+ .script(new Script(ScriptType.INLINE, "native", DummyScript.NAME, Collections.emptyMap())) ).get());
assertThat(e.getMessage(), containsString("[ip_range] does not support scripts"));
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsIT.java
index b97773311c..1739d09a05 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsIT.java
@@ -442,7 +442,7 @@ public class LongTermsIT extends AbstractTermsTestCase {
.addAggregation(terms("terms")
.field(SINGLE_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -495,7 +495,7 @@ public class LongTermsIT extends AbstractTermsTestCase {
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("_value - 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value - 1", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -524,7 +524,8 @@ public class LongTermsIT extends AbstractTermsTestCase {
.addAggregation(terms("terms")
.field(MULTI_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("floor(_value / 1000 + 1)", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(
+ ScriptType.INLINE, CustomScriptPlugin.NAME, "floor(_value / 1000 + 1)", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -560,7 +561,8 @@ public class LongTermsIT extends AbstractTermsTestCase {
*/
public void testScriptSingleValue() throws Exception {
- Script script = new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -586,7 +588,8 @@ public class LongTermsIT extends AbstractTermsTestCase {
}
public void testScriptMultiValued() throws Exception {
- Script script = new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + MULTI_VALUED_FIELD_NAME + "']", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(terms("terms")
@@ -1157,7 +1160,8 @@ public class LongTermsIT extends AbstractTermsTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(
- terms("terms").field("d").script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null))).get();
+ terms("terms").field("d").script(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountIT.java
index 91885d5f5a..925ff86232 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountIT.java
@@ -151,8 +151,8 @@ public class MinDocCountIT extends AbstractTermsTestCase {
YES {
@Override
TermsAggregationBuilder apply(TermsAggregationBuilder builder, String field) {
- return builder.script(new org.elasticsearch.script.Script("doc['" + field + "'].values", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null));
+ return builder.script(new org.elasticsearch.script.Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "doc['" + field + "'].values", Collections.emptyMap()));
}
};
abstract TermsAggregationBuilder apply(TermsAggregationBuilder builder, String field);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java
index eb2a668bcb..fc4fac72ee 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java
@@ -394,7 +394,7 @@ public class RangeIT extends ESIntegTestCase {
.addAggregation(
range("range")
.field(SINGLE_VALUED_FIELD_NAME)
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap()))
.addUnboundedTo(3)
.addRange(3, 6)
.addUnboundedFrom(6))
@@ -514,7 +514,7 @@ public class RangeIT extends ESIntegTestCase {
.addAggregation(
range("range")
.field(MULTI_VALUED_FIELD_NAME)
- .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap()))
.addUnboundedTo(3)
.addRange(3, 6)
.addUnboundedFrom(6))
@@ -575,7 +575,8 @@ public class RangeIT extends ESIntegTestCase {
*/
public void testScriptSingleValue() throws Exception {
- Script script = new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
@@ -660,7 +661,8 @@ public class RangeIT extends ESIntegTestCase {
}
public void testScriptMultiValued() throws Exception {
- Script script = new Script("doc['" + MULTI_VALUED_FIELD_NAME + "'].values", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + MULTI_VALUED_FIELD_NAME + "'].values", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -933,7 +935,8 @@ public class RangeIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("fieldname", "date");
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(
- range("foo").field("i").script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)).addRange(0, 10))
+ range("foo").field("i").script(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value + 1", Collections.emptyMap())).addRange(0, 10))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java
index d9bf07d4d3..8852716377 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java
@@ -56,6 +56,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -507,14 +508,13 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
}
private ScriptHeuristic getScriptSignificanceHeuristic() throws IOException {
- Script script = null;
+ Script script;
if (randomBoolean()) {
- Map<String, Object> params = null;
- params = new HashMap<>();
+ Map<String, Object> params = new HashMap<>();
params.put("param", randomIntBetween(1, 100));
- script = new Script("native_significance_score_script_with_params", ScriptType.INLINE, "native", params);
+ script = new Script(ScriptType.INLINE, "native", "native_significance_score_script_with_params", params);
} else {
- script = new Script("native_significance_score_script_no_params", ScriptType.INLINE, "native", null);
+ script = new Script(ScriptType.INLINE, "native", "native_significance_score_script_no_params", Collections.emptyMap());
}
return new ScriptHeuristic(script);
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java
index 30f9e3c97a..3d5d13bf04 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java
@@ -575,7 +575,7 @@ public class StringTermsIT extends AbstractTermsTestCase {
.executionHint(randomExecutionHint())
.field(SINGLE_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("'foo_' + _value", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "'foo_' + _value", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -602,7 +602,8 @@ public class StringTermsIT extends AbstractTermsTestCase {
.executionHint(randomExecutionHint())
.field(MULTI_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("_value.substring(0,3)", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(
+ ScriptType.INLINE, CustomScriptPlugin.NAME, "_value.substring(0,3)", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -652,7 +653,8 @@ public class StringTermsIT extends AbstractTermsTestCase {
.addAggregation(
terms("terms")
.executionHint(randomExecutionHint())
- .script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "doc['" + MULTI_VALUED_FIELD_NAME + "']", Collections.emptyMap()))
.collectMode(randomFrom(SubAggCollectionMode.values())))
.get();
@@ -684,7 +686,7 @@ public class StringTermsIT extends AbstractTermsTestCase {
.executionHint(randomExecutionHint())
.field(MULTI_VALUED_FIELD_NAME)
.collectMode(randomFrom(SubAggCollectionMode.values()))
- .script(new Script("'foo_' + _value", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "'foo_' + _value", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -719,7 +721,8 @@ public class StringTermsIT extends AbstractTermsTestCase {
*/
public void testScriptSingleValue() throws Exception {
- Script script = new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -747,7 +750,8 @@ public class StringTermsIT extends AbstractTermsTestCase {
}
public void testScriptSingleValueExplicitSingleValue() throws Exception {
- Script script = new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + SINGLE_VALUED_FIELD_NAME + "'].value", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -782,7 +786,8 @@ public class StringTermsIT extends AbstractTermsTestCase {
terms("terms")
.collectMode(randomFrom(SubAggCollectionMode.values()))
.executionHint(randomExecutionHint())
- .script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "doc['" + MULTI_VALUED_FIELD_NAME + "']", Collections.emptyMap())))
.get();
assertSearchResponse(response);
@@ -1533,7 +1538,8 @@ public class StringTermsIT extends AbstractTermsTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
.addAggregation(
- terms("terms").field("d").script(new Script("'foo_' + _value", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ terms("terms").field("d").script(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "'foo_' + _value", Collections.emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java
index a1ca541129..66fd9653c4 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java
@@ -167,7 +167,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("value")
- .script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, null)))
+ .script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -184,7 +184,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("value")
- .script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, params)))
+ .script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -228,7 +228,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("values")
- .script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, null)))
+ .script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -245,7 +245,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg").field("values")
- .script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, params)))
+ .script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -261,7 +261,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg")
- .script(new Script("value", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, null)))
+ .script(new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "value", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -278,7 +278,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg")
- .script(new Script("value", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, params)))
+ .script(new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "value", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -294,7 +294,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg")
- .script(new Script("values", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, null)))
+ .script(new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "values", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -311,7 +311,7 @@ public class AvgIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(avg("avg")
- .script(new Script("values", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, params)))
+ .script(new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "values", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -371,7 +371,8 @@ public class AvgIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
- .addAggregation(avg("foo").field("d").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, null))).get();
+ .addAggregation(avg("foo").field("d").script(
+ new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", Collections.emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java
index 4c22a38f6f..17785d2cb3 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java
@@ -306,7 +306,7 @@ public class CardinalityIT extends ESIntegTestCase {
.addAggregation(
cardinality("cardinality")
.precisionThreshold(precisionThreshold)
- .script(new Script("doc['str_value'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_value'].value", emptyMap())))
.execute().actionGet();
assertSearchResponse(response);
@@ -322,7 +322,7 @@ public class CardinalityIT extends ESIntegTestCase {
.addAggregation(
cardinality("cardinality")
.precisionThreshold(precisionThreshold)
- .script(new Script("doc['str_values'].values", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_values'].values", emptyMap())))
.execute().actionGet();
assertSearchResponse(response);
@@ -334,7 +334,7 @@ public class CardinalityIT extends ESIntegTestCase {
}
public void testSingleValuedNumericScript() throws Exception {
- Script script = new Script("doc[' + singleNumericField() + '].value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc[' + singleNumericField() + '].value", emptyMap());
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script(script))
.execute().actionGet();
@@ -348,7 +348,8 @@ public class CardinalityIT extends ESIntegTestCase {
}
public void testMultiValuedNumericScript() throws Exception {
- Script script = new Script("doc[' + multiNumericField(false) + '].values", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc[' + multiNumericField(false) + '].values", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx").setTypes("type")
.addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script(script))
.execute().actionGet();
@@ -367,7 +368,7 @@ public class CardinalityIT extends ESIntegTestCase {
cardinality("cardinality")
.precisionThreshold(precisionThreshold)
.field("str_value")
- .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap())))
.execute().actionGet();
assertSearchResponse(response);
@@ -384,7 +385,7 @@ public class CardinalityIT extends ESIntegTestCase {
cardinality("cardinality")
.precisionThreshold(precisionThreshold)
.field("str_values")
- .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap())))
.execute().actionGet();
assertSearchResponse(response);
@@ -401,7 +402,7 @@ public class CardinalityIT extends ESIntegTestCase {
cardinality("cardinality")
.precisionThreshold(precisionThreshold)
.field(singleNumericField())
- .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap())))
.execute().actionGet();
assertSearchResponse(response);
@@ -418,7 +419,7 @@ public class CardinalityIT extends ESIntegTestCase {
cardinality("cardinality")
.precisionThreshold(precisionThreshold)
.field(multiNumericField(false))
- .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap())))
.execute().actionGet();
assertSearchResponse(response);
@@ -467,7 +468,7 @@ public class CardinalityIT extends ESIntegTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
.addAggregation(
- cardinality("foo").field("d").script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
+ cardinality("foo").field("d").script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value", emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java
index ce700d22da..6eb0bba6ae 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java
@@ -301,7 +301,8 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
.addAggregation(
extendedStats("stats")
.field("value")
- .script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE,
+ AggregationTestScriptsPlugin.NAME, "_value + 1", Collections.emptyMap()))
.sigma(sigma))
.execute().actionGet();
@@ -331,7 +332,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
.addAggregation(
extendedStats("stats")
.field("value")
- .script(new Script("_value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + inc", params))
.sigma(sigma))
.execute().actionGet();
@@ -383,7 +384,8 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
.addAggregation(
extendedStats("stats")
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE,
+ AggregationTestScriptsPlugin.NAME, "_value - 1", Collections.emptyMap()))
.sigma(sigma))
.execute().actionGet();
@@ -413,7 +415,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
.addAggregation(
extendedStats("stats")
.field("values")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.sigma(sigma))
.get();
@@ -440,7 +442,8 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
.setQuery(matchAllQuery())
.addAggregation(
extendedStats("stats")
- .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE,
+ AggregationTestScriptsPlugin.NAME, "doc['value'].value", Collections.emptyMap()))
.sigma(sigma))
.execute().actionGet();
@@ -465,7 +468,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
- Script script = new Script("doc['value'].value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value + inc", params);
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -499,7 +502,8 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
.setQuery(matchAllQuery())
.addAggregation(
extendedStats("stats")
- .script(new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null))
+ .script(new Script(ScriptType.INLINE,
+ AggregationTestScriptsPlugin.NAME, "doc['values'].values", Collections.emptyMap()))
.sigma(sigma))
.execute().actionGet();
@@ -524,8 +528,8 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("[ doc['value'].value, doc['value'].value - dec ]", ScriptType.INLINE,
- AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "[ doc['value'].value, doc['value'].value - dec ]",
+ params);
double sigma = randomDouble() * randomIntBetween(1, 10);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -653,7 +657,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
.addAggregation(extendedStats("foo").field("d")
- .script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", Collections.emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java
index a77388fc03..2918428519 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java
@@ -260,7 +260,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
.method(PercentilesMethod.HDR)
.numberOfSignificantValueDigits(sigDigits)
.field("value")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -284,7 +284,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
.method(PercentilesMethod.HDR)
.numberOfSignificantValueDigits(sigDigits)
.field("value")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.values(pcts))
.execute().actionGet();
@@ -324,7 +324,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
.method(PercentilesMethod.HDR)
.numberOfSignificantValueDigits(sigDigits)
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -345,7 +345,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
.method(PercentilesMethod.HDR)
.numberOfSignificantValueDigits(sigDigits)
.field("values")
- .script(new Script("20 - _value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "20 - _value", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -369,7 +369,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
.method(PercentilesMethod.HDR)
.numberOfSignificantValueDigits(sigDigits)
.field("values")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.values(pcts))
.execute().actionGet();
@@ -390,7 +390,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
percentileRanks("percentile_ranks")
.method(PercentilesMethod.HDR)
.numberOfSignificantValueDigits(sigDigits)
- .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -406,7 +406,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value - dec", params);
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client()
@@ -431,7 +431,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
int sigDigits = randomSignificantDigits();
final double[] pcts = randomPercents(minValues, maxValues);
- Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client()
.prepareSearch("idx")
@@ -553,7 +553,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client()
.prepareSearch("cache_test_idx").setSize(0).addAggregation(percentileRanks("foo").method(PercentilesMethod.HDR).field("d")
- .values(50.0).script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .values(50.0).script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java
index 6e27e5b504..32fdd02a87 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java
@@ -245,7 +245,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
.numberOfSignificantValueDigits(sigDigits)
.method(PercentilesMethod.HDR)
.field("value")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -270,7 +270,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
.numberOfSignificantValueDigits(sigDigits)
.method(PercentilesMethod.HDR)
.field("value")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.percentiles(pcts))
.execute().actionGet();
@@ -310,7 +310,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
.numberOfSignificantValueDigits(sigDigits)
.method(PercentilesMethod.HDR)
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -331,7 +331,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
.numberOfSignificantValueDigits(sigDigits)
.method(PercentilesMethod.HDR)
.field("values")
- .script(new Script("20 - _value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "20 - _value", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -356,7 +356,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
.numberOfSignificantValueDigits(sigDigits)
.method(PercentilesMethod.HDR)
.field("values")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.percentiles(pcts))
.execute().actionGet();
@@ -377,7 +377,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
percentiles("percentiles")
.numberOfSignificantValueDigits(sigDigits)
.method(PercentilesMethod.HDR)
- .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -392,7 +392,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value - dec", params);
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
@@ -418,7 +418,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
final double[] pcts = randomPercentiles();
int sigDigits = randomSignificantDigits();
- Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client()
.prepareSearch("idx")
@@ -544,7 +544,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
.addAggregation(percentiles("foo").method(PercentilesMethod.HDR).field("d").percentiles(50.0)
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxIT.java
index c692082aaa..4a651a0ad5 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxIT.java
@@ -165,7 +165,7 @@ public class MaxIT extends AbstractNumericTestCase {
.addAggregation(
max("max")
.field("value")
- .script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -185,7 +185,7 @@ public class MaxIT extends AbstractNumericTestCase {
.addAggregation(
max("max")
.field("value")
- .script(new Script("_value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params)))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + inc", params)))
.get();
assertHitCount(searchResponse, 10);
@@ -218,7 +218,7 @@ public class MaxIT extends AbstractNumericTestCase {
.addAggregation(
max("max")
.field("values")
- .script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", emptyMap())))
.get();
assertHitCount(searchResponse, 10);
@@ -238,7 +238,7 @@ public class MaxIT extends AbstractNumericTestCase {
.addAggregation(
max("max")
.field("values")
- .script(new Script("_value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params)))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + inc", params)))
.get();
assertHitCount(searchResponse, 10);
@@ -255,7 +255,7 @@ public class MaxIT extends AbstractNumericTestCase {
.setQuery(matchAllQuery())
.addAggregation(
max("max")
- .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -271,7 +271,7 @@ public class MaxIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
- Script script = new Script("doc['value'].value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value + inc", params);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -292,7 +292,8 @@ public class MaxIT extends AbstractNumericTestCase {
.setQuery(matchAllQuery())
.addAggregation(
max("max")
- .script(new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null)))
+ .script(new Script(ScriptType.INLINE,
+ AggregationTestScriptsPlugin.NAME, "doc['values'].values", Collections.emptyMap())))
.get();
assertHitCount(searchResponse, 10);
@@ -308,8 +309,8 @@ public class MaxIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
- Script script = new Script("[ doc['value'].value, doc['value'].value + inc ]", ScriptType.INLINE,
- AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "[ doc['value'].value, doc['value'].value + inc ]",
+ params);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(max("max").script(script))
@@ -372,7 +373,7 @@ public class MaxIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(
- max("foo").field("d").script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ max("foo").field("d").script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MinIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MinIT.java
index dc6c7d0853..dde1c840ee 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MinIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/MinIT.java
@@ -166,7 +166,7 @@ public class MinIT extends AbstractNumericTestCase {
.addAggregation(
min("min")
.field("value")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertHitCount(searchResponse, 10);
@@ -182,7 +182,7 @@ public class MinIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -219,7 +219,7 @@ public class MinIT extends AbstractNumericTestCase {
.addAggregation(
min("min")
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertHitCount(searchResponse, 10);
@@ -237,7 +237,7 @@ public class MinIT extends AbstractNumericTestCase {
.addAggregation(
min("min")
.field("values")
- .script(new Script("_value * -1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value * -1", emptyMap())))
.get();
assertHitCount(searchResponse, 10);
@@ -253,7 +253,7 @@ public class MinIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").field("values").script(script))
@@ -269,7 +269,7 @@ public class MinIT extends AbstractNumericTestCase {
@Override
public void testScriptSingleValued() throws Exception {
- Script script = new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").script(script))
@@ -288,7 +288,7 @@ public class MinIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value - dec", params);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").script(script))
@@ -304,7 +304,7 @@ public class MinIT extends AbstractNumericTestCase {
@Override
public void testScriptMultiValued() throws Exception {
- Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
.addAggregation(min("min").script(script))
.get();
@@ -385,7 +385,7 @@ public class MinIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(
- min("foo").field("d").script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ min("foo").field("d").script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricIT.java
index 12f512efaa..545c10bcb0 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricIT.java
@@ -277,7 +277,7 @@ public class ScriptedMetricIT extends ESIntegTestCase {
}
public void testMap() {
- Script mapScript = new Script("_agg['count'] = 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg['count'] = 1", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -317,7 +317,7 @@ public class ScriptedMetricIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("_agg", new ArrayList<>());
- Script mapScript = new Script("_agg.add(1)", ScriptType.INLINE, CustomScriptPlugin.NAME, params);
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(1)", params);
SearchResponse response = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -365,8 +365,10 @@ public class ScriptedMetricIT extends ESIntegTestCase {
.addAggregation(
scriptedMetric("scripted")
.params(params)
- .initScript(new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .mapScript(new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .initScript(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap()))
+ .mapScript(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "_agg.add(vars.multiplier)", Collections.emptyMap())))
.get();
assertSearchResponse(response);
assertThat(response.getHits().getTotalHits(), equalTo(numDocs));
@@ -404,8 +406,9 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script mapScript = new Script("_agg.add(1)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(1)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -455,9 +458,10 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -508,10 +512,12 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -551,10 +557,12 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse searchResponse = client()
.prepareSearch("idx")
@@ -605,9 +613,11 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -645,9 +655,10 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -684,8 +695,9 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -725,11 +737,12 @@ public class ScriptedMetricIT extends ESIntegTestCase {
Map<String, Object> reduceParams = new HashMap<>();
reduceParams.put("multiplier", 4);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("multiplied sum aggs of agg values as a new aggregation", ScriptType.INLINE,
- CustomScriptPlugin.NAME, reduceParams);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "multiplied sum aggs of agg values as a new aggregation", reduceParams);
SearchResponse response = client()
.prepareSearch("idx")
@@ -774,10 +787,14 @@ public class ScriptedMetricIT extends ESIntegTestCase {
.addAggregation(
scriptedMetric("scripted")
.params(params)
- .initScript(new Script("initScript_stored", ScriptType.STORED, CustomScriptPlugin.NAME, null))
- .mapScript(new Script("mapScript_stored", ScriptType.STORED, CustomScriptPlugin.NAME, null))
- .combineScript(new Script("combineScript_stored", ScriptType.STORED, CustomScriptPlugin.NAME, null))
- .reduceScript(new Script("reduceScript_stored", ScriptType.STORED, CustomScriptPlugin.NAME, null)))
+ .initScript(
+ new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "initScript_stored", Collections.emptyMap()))
+ .mapScript(
+ new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "mapScript_stored", Collections.emptyMap()))
+ .combineScript(
+ new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "combineScript_stored", Collections.emptyMap()))
+ .reduceScript(
+ new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "reduceScript_stored", Collections.emptyMap())))
.get();
assertSearchResponse(response);
assertThat(response.getHits().getTotalHits(), equalTo(numDocs));
@@ -810,10 +827,12 @@ public class ScriptedMetricIT extends ESIntegTestCase {
.addAggregation(
scriptedMetric("scripted")
.params(params)
- .initScript(new Script("init_script", ScriptType.FILE, CustomScriptPlugin.NAME, null))
- .mapScript(new Script("map_script", ScriptType.FILE, CustomScriptPlugin.NAME, null))
- .combineScript(new Script("combine_script", ScriptType.FILE, CustomScriptPlugin.NAME, null))
- .reduceScript(new Script("reduce_script", ScriptType.FILE, CustomScriptPlugin.NAME, null)))
+ .initScript(new Script(ScriptType.FILE, CustomScriptPlugin.NAME, "init_script", Collections.emptyMap()))
+ .mapScript(new Script(ScriptType.FILE, CustomScriptPlugin.NAME, "map_script", Collections.emptyMap()))
+ .combineScript(
+ new Script(ScriptType.FILE, CustomScriptPlugin.NAME, "combine_script", Collections.emptyMap()))
+ .reduceScript(
+ new Script(ScriptType.FILE, CustomScriptPlugin.NAME, "reduce_script", Collections.emptyMap())))
.get();
assertSearchResponse(response);
assertThat(response.getHits().getTotalHits(), equalTo(numDocs));
@@ -841,10 +860,12 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -900,10 +921,12 @@ public class ScriptedMetricIT extends ESIntegTestCase {
params.put("_agg", new ArrayList<>());
params.put("vars", varsMap);
- Script initScript = new Script("vars.multiplier = 3", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script mapScript = new Script("_agg.add(vars.multiplier)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script combineScript = new Script("sum agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script reduceScript = new Script("sum aggs of agg values as a new aggregation", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script initScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "vars.multiplier = 3", Collections.emptyMap());
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg.add(vars.multiplier)", Collections.emptyMap());
+ Script combineScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum agg values as a new aggregation", Collections.emptyMap());
+ Script reduceScript =
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "sum aggs of agg values as a new aggregation", Collections.emptyMap());
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
@@ -939,7 +962,7 @@ public class ScriptedMetricIT extends ESIntegTestCase {
* not using a script does get cached.
*/
public void testDontCacheScripts() throws Exception {
- Script mapScript = new Script("_agg['count'] = 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script mapScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_agg['count'] = 1", Collections.emptyMap());
assertAcked(prepareCreate("cache_test_idx").addMapping("type", "d", "type=long")
.setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1))
.get());
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java
index e75d14bc87..11c6ed7f6a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java
@@ -24,6 +24,7 @@ import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.aggregations.BaseAggregationTestCase;
import org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetricAggregationBuilder;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -54,7 +55,8 @@ public class ScriptedMetricTests extends BaseAggregationTestCase<ScriptedMetricA
if (randomBoolean()) {
return new Script(script);
} else {
- return new Script(script, randomFrom(ScriptType.values()), randomFrom("my_lang", null), null);
+ return new Script(
+ randomFrom(ScriptType.values()), randomFrom("my_lang", Script.DEFAULT_SCRIPT_LANG), script, Collections.emptyMap());
}
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsIT.java
index dddf74446d..8096299f6e 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsIT.java
@@ -229,7 +229,7 @@ public class StatsIT extends AbstractNumericTestCase {
.addAggregation(
stats("stats")
.field("value")
- .script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", emptyMap())))
.get();
assertShardExecutionState(searchResponse, 0);
@@ -255,7 +255,7 @@ public class StatsIT extends AbstractNumericTestCase {
.addAggregation(
stats("stats")
.field("value")
- .script(new Script("_value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params)))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + inc", params)))
.get();
assertShardExecutionState(searchResponse, 0);
@@ -300,7 +300,7 @@ public class StatsIT extends AbstractNumericTestCase {
.addAggregation(
stats("stats")
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertShardExecutionState(searchResponse, 0);
@@ -326,7 +326,7 @@ public class StatsIT extends AbstractNumericTestCase {
.addAggregation(
stats("stats")
.field("values")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params)))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params)))
.get();
assertShardExecutionState(searchResponse, 0);
@@ -349,7 +349,7 @@ public class StatsIT extends AbstractNumericTestCase {
.setQuery(matchAllQuery())
.addAggregation(
stats("stats")
- .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap())))
.get();
assertShardExecutionState(searchResponse, 0);
@@ -371,7 +371,7 @@ public class StatsIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("inc", 1);
- Script script = new Script("doc['value'].value + inc", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value + inc", params);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -394,7 +394,7 @@ public class StatsIT extends AbstractNumericTestCase {
@Override
public void testScriptMultiValued() throws Exception {
- Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -420,8 +420,8 @@ public class StatsIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("[ doc['value'].value, doc['value'].value - dec ]", ScriptType.INLINE,
- AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "[ doc['value'].value, doc['value'].value - dec ]",
+ params);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -508,7 +508,8 @@ public class StatsIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(
- stats("foo").field("d").script(new Script("_value + 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, null))).get();
+ stats("foo").field("d").script(
+ new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + 1", Collections.emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java
index b2609c7654..61c80d648a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java
@@ -44,6 +44,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -175,7 +176,8 @@ public class SumIT extends AbstractNumericTestCase {
public void testSingleValuedFieldWithValueScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
- .addAggregation(sum("sum").field("value").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, null)))
+ .addAggregation(sum("sum").field("value").script(
+ new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -192,7 +194,7 @@ public class SumIT extends AbstractNumericTestCase {
params.put("increment", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
- .addAggregation(sum("sum").field("value").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, params)))
+ .addAggregation(sum("sum").field("value").script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -207,7 +209,8 @@ public class SumIT extends AbstractNumericTestCase {
public void testScriptSingleValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
- .addAggregation(sum("sum").script(new Script("value", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, null)))
+ .addAggregation(sum("sum").script(
+ new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "value", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -224,7 +227,7 @@ public class SumIT extends AbstractNumericTestCase {
params.put("inc", 1);
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
- .addAggregation(sum("sum").script(new Script("value", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, params)))
+ .addAggregation(sum("sum").script(new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "value", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -239,7 +242,8 @@ public class SumIT extends AbstractNumericTestCase {
public void testScriptMultiValued() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
- .addAggregation(sum("sum").script(new Script("values", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, null)))
+ .addAggregation(sum("sum").script(
+ new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "values", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -257,7 +261,7 @@ public class SumIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(
- sum("sum").script(new Script("values", ScriptType.INLINE, ExtractFieldScriptEngine.NAME, params)))
+ sum("sum").script(new Script(ScriptType.INLINE, ExtractFieldScriptEngine.NAME, "values", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -289,7 +293,8 @@ public class SumIT extends AbstractNumericTestCase {
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
- .addAggregation(sum("sum").field("values").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, null)))
+ .addAggregation(sum("sum").field("values").script(
+ new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", Collections.emptyMap())))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -305,7 +310,7 @@ public class SumIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("increment", 1);
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
- .addAggregation(sum("sum").field("values").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, params)))
+ .addAggregation(sum("sum").field("values").script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", params)))
.execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -365,7 +370,8 @@ public class SumIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
- .addAggregation(sum("foo").field("d").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, null))).get();
+ .addAggregation(sum("foo").field("d").script(
+ new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", Collections.emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java
index 3e48222950..67ac485502 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java
@@ -241,7 +241,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
randomCompression(
percentileRanks("percentile_ranks"))
.field("value")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -262,7 +262,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
randomCompression(
percentileRanks("percentile_ranks"))
.field("value")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.values(pcts))
.execute().actionGet();
@@ -297,7 +297,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
randomCompression(
percentileRanks("percentile_ranks"))
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -315,7 +315,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
randomCompression(
percentileRanks("percentile_ranks"))
.field("values")
- .script(new Script("_value * -1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value * -1", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -336,7 +336,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
randomCompression(
percentileRanks("percentile_ranks"))
.field("values")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.values(pcts))
.execute().actionGet();
@@ -354,7 +354,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
.addAggregation(
randomCompression(
percentileRanks("percentile_ranks"))
- .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap()))
.values(pcts))
.execute().actionGet();
@@ -369,7 +369,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value - dec", params);
final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -390,7 +390,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
@Override
public void testScriptMultiValued() throws Exception {
final double[] pcts = randomPercents(minValues, maxValues);
- Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
.addAggregation(
@@ -502,7 +502,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(percentileRanks("foo").field("d").values(50.0)
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))).get();
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java
index 71f3692a25..dbc7993c51 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java
@@ -226,7 +226,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
randomCompression(
percentiles("percentiles"))
.field("value")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -247,7 +247,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
randomCompression(
percentiles("percentiles"))
.field("value")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.percentiles(pcts))
.execute().actionGet();
@@ -280,7 +280,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
randomCompression(
percentiles("percentiles"))
.field("values")
- .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -298,7 +298,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
randomCompression(
percentiles("percentiles"))
.field("values")
- .script(new Script("_value * -1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value * -1", emptyMap()))
.percentiles(pcts))
.execute().actionGet();
@@ -319,7 +319,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
randomCompression(
percentiles("percentiles"))
.field("values")
- .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+ .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
.percentiles(pcts))
.execute().actionGet();
@@ -331,7 +331,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
@Override
public void testScriptSingleValued() throws Exception {
- Script script = new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", emptyMap());
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -353,7 +353,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
Map<String, Object> params = new HashMap<>();
params.put("dec", 1);
- Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value - dec", params);
final double[] pcts = randomPercentiles();
SearchResponse searchResponse = client().prepareSearch("idx")
@@ -374,7 +374,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
@Override
public void testScriptMultiValued() throws Exception {
final double[] pcts = randomPercentiles();
- Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+ Script script = new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['values'].values", emptyMap());
SearchResponse searchResponse = client().prepareSearch("idx")
.setQuery(matchAllQuery())
@@ -488,7 +488,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0).addAggregation(percentiles("foo").field("d")
- .percentiles(50.0).script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap())))
+ .percentiles(50.0).script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - 1", emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java
index 3cdcbf3c1c..4bc640dc90 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java
@@ -583,7 +583,7 @@ public class TopHitsIT extends ESIntegTestCase {
.explain(true)
.storedField("text")
.fieldDataField("field1")
- .scriptField("script", new Script("5", ScriptType.INLINE, MockScriptEngine.NAME, Collections.emptyMap()))
+ .scriptField("script", new Script(ScriptType.INLINE, MockScriptEngine.NAME, "5", Collections.emptyMap()))
.fetchSource("text", null)
.version(true)
)
@@ -865,7 +865,7 @@ public class TopHitsIT extends ESIntegTestCase {
nested("to-comments", "comments").subAggregation(
topHits("top-comments").size(1).highlighter(new HighlightBuilder().field(hlField)).explain(true)
.fieldDataField("comments.user")
- .scriptField("script", new Script("5", ScriptType.INLINE, MockScriptEngine.NAME, Collections.emptyMap())).fetchSource("comments.message", null)
+ .scriptField("script", new Script(ScriptType.INLINE, MockScriptEngine.NAME, "5", Collections.emptyMap())).fetchSource("comments.message", null)
.version(true).sort("comments.date", SortOrder.ASC))).get();
assertHitCount(searchResponse, 2);
Nested nested = searchResponse.getAggregations().get("to-comments");
@@ -1014,7 +1014,8 @@ public class TopHitsIT extends ESIntegTestCase {
// Test that a request using a script field does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
- .addAggregation(topHits("foo").scriptField("bar", new Script("5", ScriptType.INLINE, CustomScriptPlugin.NAME, null))).get();
+ .addAggregation(topHits("foo").scriptField("bar",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "5", Collections.emptyMap()))).get();
assertSearchResponse(r);
assertThat(client().admin().indices().prepareStats("cache_test_idx").setRequestCache(true).get().getTotal().getRequestCache()
@@ -1025,7 +1026,8 @@ public class TopHitsIT extends ESIntegTestCase {
// Test that a request using a script sort does not get cached
r = client().prepareSearch("cache_test_idx").setSize(0)
.addAggregation(topHits("foo").sort(
- SortBuilders.scriptSort(new Script("5", ScriptType.INLINE, CustomScriptPlugin.NAME, null), ScriptSortType.STRING)))
+ SortBuilders.scriptSort(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "5", Collections.emptyMap()), ScriptSortType.STRING)))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java
index 4d421892b6..72a546885c 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java
@@ -157,7 +157,7 @@ public class ValueCountIT extends ESIntegTestCase {
public void testSingleValuedScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
- .addAggregation(count("count").script(new Script("value", ScriptType.INLINE, FieldValueScriptEngine.NAME, null))).execute().actionGet();
+ .addAggregation(count("count").script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "value", Collections.emptyMap()))).execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -169,7 +169,7 @@ public class ValueCountIT extends ESIntegTestCase {
public void testMultiValuedScript() throws Exception {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
- .addAggregation(count("count").script(new Script("values", ScriptType.INLINE, FieldValueScriptEngine.NAME, null))).execute().actionGet();
+ .addAggregation(count("count").script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "values", Collections.emptyMap()))).execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -182,7 +182,7 @@ public class ValueCountIT extends ESIntegTestCase {
public void testSingleValuedScriptWithParams() throws Exception {
Map<String, Object> params = Collections.singletonMap("s", "value");
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
- .addAggregation(count("count").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, params))).execute().actionGet();
+ .addAggregation(count("count").script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", params))).execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -195,7 +195,7 @@ public class ValueCountIT extends ESIntegTestCase {
public void testMultiValuedScriptWithParams() throws Exception {
Map<String, Object> params = Collections.singletonMap("s", "values");
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
- .addAggregation(count("count").script(new Script("", ScriptType.INLINE, FieldValueScriptEngine.NAME, params))).execute().actionGet();
+ .addAggregation(count("count").script(new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "", params))).execute().actionGet();
assertHitCount(searchResponse, 10);
@@ -224,7 +224,8 @@ public class ValueCountIT extends ESIntegTestCase {
// Test that a request using a script does not get cached
SearchResponse r = client().prepareSearch("cache_test_idx").setSize(0)
- .addAggregation(count("foo").field("d").script(new Script("value", ScriptType.INLINE, FieldValueScriptEngine.NAME, null)))
+ .addAggregation(count("foo").field("d").script(
+ new Script(ScriptType.INLINE, FieldValueScriptEngine.NAME, "value", Collections.emptyMap())))
.get();
assertSearchResponse(r);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptIT.java
index 47846eaaba..e76b02a8c9 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptIT.java
@@ -164,8 +164,9 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0 + _value1 + _value2", ScriptType.INLINE, CustomScriptPlugin.NAME, null)
- , "field2Sum", "field3Sum", "field4Sum")))
+ new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
+ "field2Sum", "field3Sum", "field4Sum")))
.execute().actionGet();
assertSearchResponse(response);
@@ -210,7 +211,8 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0 + _value1 / _value2", ScriptType.INLINE, CustomScriptPlugin.NAME, null),
+ new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "_value0 + _value1 / _value2", Collections.emptyMap()),
"field2Sum", "field3Sum", "field4Sum")))
.execute().actionGet();
@@ -256,7 +258,7 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0 + _value1 + _value2", ScriptType.INLINE, CustomScriptPlugin.NAME, null)
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap())
, "field2Sum", "field3Sum", "field4Sum")))
.execute().actionGet();
@@ -300,7 +302,7 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0", ScriptType.INLINE, CustomScriptPlugin.NAME, null),
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value0", Collections.emptyMap()),
"field2Sum")))
.execute().actionGet();
@@ -344,7 +346,8 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic", bucketsPathsMap,
- new Script("foo + bar + baz", ScriptType.INLINE, CustomScriptPlugin.NAME, null))))
+ new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "foo + bar + baz", Collections.emptyMap()))))
.execute().actionGet();
assertSearchResponse(response);
@@ -381,7 +384,7 @@ public class BucketScriptIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("factor", 3);
- Script script = new Script("(_value0 + _value1 + _value2) * factor", ScriptType.INLINE, CustomScriptPlugin.NAME, params);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "(_value0 + _value1 + _value2) * factor", params);
SearchResponse response = client()
.prepareSearch("idx")
@@ -437,7 +440,8 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0 + _value1 + _value2", ScriptType.INLINE, CustomScriptPlugin.NAME, null),
+ new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
"field2Sum", "field3Sum", "field4Sum").gapPolicy(GapPolicy.INSERT_ZEROS)))
.execute().actionGet();
@@ -491,7 +495,7 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("my_script", ScriptType.STORED, CustomScriptPlugin.NAME, null),
+ new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "my_script", Collections.emptyMap()),
"field2Sum", "field3Sum", "field4Sum"))).execute().actionGet();
assertSearchResponse(response);
@@ -536,7 +540,8 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0 + _value1 + _value2", ScriptType.INLINE, CustomScriptPlugin.NAME, null),
+ new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
"field2Sum", "field3Sum", "field4Sum")))
.execute().actionGet();
@@ -560,7 +565,8 @@ public class BucketScriptIT extends ESIntegTestCase {
.subAggregation(sum("field4Sum").field(FIELD_4_NAME))
.subAggregation(
bucketScript("seriesArithmetic",
- new Script("_value0 + _value1 + _value2", ScriptType.INLINE, CustomScriptPlugin.NAME, null),
+ new Script(ScriptType.INLINE,
+ CustomScriptPlugin.NAME, "_value0 + _value1 + _value2", Collections.emptyMap()),
"field2Sum", "field3Sum", "field4Sum"))).execute().actionGet();
assertSearchResponse(response);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java
index 4b79977cf5..d485a0b6d8 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java
@@ -42,12 +42,11 @@ public class BucketScriptTests extends BasePipelineAggregationTestCase<BucketScr
if (randomBoolean()) {
script = new Script("script");
} else {
- Map<String, Object> params = null;
+ Map<String, Object> params = new HashMap<>();
if (randomBoolean()) {
- params = new HashMap<String, Object>();
params.put("foo", "bar");
}
- script = new Script("script", randomFrom(ScriptType.values()), randomFrom("my_lang", null), params);
+ script = new Script(randomFrom(ScriptType.values()), randomFrom("my_lang", Script.DEFAULT_SCRIPT_LANG), "script", params);
}
BucketScriptPipelineAggregationBuilder factory = new BucketScriptPipelineAggregationBuilder(name, bucketsPaths, script);
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorIT.java
index e300a72bc3..67261ee02a 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorIT.java
@@ -176,8 +176,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScript() {
- Script script =
- new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx")
.addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
@@ -205,7 +205,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScriptNoBucketsPruned() {
- Script script = new Script("Double.isNaN(_value0) ? true : (_value0 < 10000)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? true : (_value0 < 10000)", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -238,7 +239,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScriptNoBucketsLeft() {
- Script script = new Script("Double.isNaN(_value0) ? false : (_value0 > 10000)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 > 10000)", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -261,7 +263,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScript2() {
- Script script = new Script("Double.isNaN(_value0) ? false : (_value0 < _value1)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 < _value1)", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -294,7 +297,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScriptSingleVariable() {
- Script script = new Script("Double.isNaN(_value0) ? false : (_value0 > 100)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 > 100)", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -323,8 +327,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScriptNamedVars() {
- Script script = new Script("Double.isNaN(my_value1) ? false : (my_value1 + my_value2 > 100)", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(my_value1) ? false : (my_value1 + my_value2 > 100)", Collections.emptyMap());
Map<String, String> bucketPathsMap = new HashMap<>();
bucketPathsMap.put("my_value1", "field2Sum");
@@ -360,8 +364,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScriptWithParams() {
- Script script = new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > threshold)", ScriptType.INLINE,
- CustomScriptPlugin.NAME, Collections.singletonMap("threshold", 100));
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 + _value1 > threshold)", Collections.singletonMap("threshold", 100));
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
@@ -393,7 +397,7 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testInlineScriptInsertZeros() {
- Script script = new Script("_value0 + _value1 > 100", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value0 + _value1 > 100", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
@@ -432,7 +436,7 @@ public class BucketSelectorIT extends ESIntegTestCase {
// Source is not interpreted but my_script is defined in CustomScriptPlugin
.setSource(new BytesArray("{ \"script\": \"Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)\" }")));
- Script script = new Script("my_script", ScriptType.STORED, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "my_script", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
@@ -465,8 +469,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testUnmapped() throws Exception {
- Script script = new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx_unmapped")
.addAggregation(
@@ -487,8 +491,8 @@ public class BucketSelectorIT extends ESIntegTestCase {
}
public void testPartiallyUnmapped() throws Exception {
- Script script = new Script("Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
+ "Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", Collections.emptyMap());
SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
.addAggregation(
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java
index 8cedbab8e8..563894906e 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java
@@ -42,12 +42,11 @@ public class BucketSelectorTests extends BasePipelineAggregationTestCase<BucketS
if (randomBoolean()) {
script = new Script("script");
} else {
- Map<String, Object> params = null;
+ Map<String, Object> params = new HashMap<>();
if (randomBoolean()) {
- params = new HashMap<String, Object>();
params.put("foo", "bar");
}
- script = new Script("script", randomFrom(ScriptType.values()), randomFrom("my_lang", null), params);
+ script = new Script(randomFrom(ScriptType.values()), randomFrom("my_lang", Script.DEFAULT_SCRIPT_LANG), "script", params);
}
BucketSelectorPipelineAggregationBuilder factory = new BucketSelectorPipelineAggregationBuilder(name, bucketsPaths, script);
if (randomBoolean()) {
diff --git a/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java b/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java
index 696af4f94e..9f03724d3c 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java
@@ -43,6 +43,7 @@ import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
@@ -450,7 +451,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
MultiSearchResponse response = client().prepareMultiSearch()
// Add custom score query with bogus script
- .add(client().prepareSearch("test").setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("nid", 1), new ScriptScoreFunctionBuilder(new Script("foo", ScriptType.INLINE, "bar", null)))))
+ .add(client().prepareSearch("test").setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("nid", 1), new ScriptScoreFunctionBuilder(new Script(ScriptType.INLINE, "bar", "foo", Collections.emptyMap())))))
.add(client().prepareSearch("test").setQuery(QueryBuilders.termQuery("nid", 2)))
.add(client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()))
.execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/search/fetch/subphase/InnerHitsIT.java b/core/src/test/java/org/elasticsearch/search/fetch/subphase/InnerHitsIT.java
index 519ea77f12..86ca66eb87 100644
--- a/core/src/test/java/org/elasticsearch/search/fetch/subphase/InnerHitsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/fetch/subphase/InnerHitsIT.java
@@ -167,7 +167,7 @@ public class InnerHitsIT extends ESIntegTestCase {
.setExplain(true)
.addDocValueField("comments.message")
.addScriptField("script",
- new Script("5", ScriptType.INLINE, MockScriptEngine.NAME, Collections.emptyMap()))
+ new Script(ScriptType.INLINE, MockScriptEngine.NAME, "5", Collections.emptyMap()))
.setSize(1)
)).get();
assertNoFailures(response);
@@ -301,8 +301,8 @@ public class InnerHitsIT extends ESIntegTestCase {
.addDocValueField("message")
.setHighlightBuilder(new HighlightBuilder().field("message"))
.setExplain(true).setSize(1)
- .addScriptField("script", new Script("5", ScriptType.INLINE,
- MockScriptEngine.NAME, Collections.emptyMap()))
+ .addScriptField("script", new Script(ScriptType.INLINE, MockScriptEngine.NAME, "5",
+ Collections.emptyMap()))
)
).get();
assertNoFailures(response);
diff --git a/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java b/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java
index d3518d5d1c..da844b1969 100644
--- a/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java
@@ -285,9 +285,12 @@ public class SearchFieldsIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch()
.setQuery(matchAllQuery())
.addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", new Script("doc['num1'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("sNum1_field", new Script("_fields['num1'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("date1", new Script("doc['date'].date.millis", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("sNum1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
+ .addScriptField("sNum1_field",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields['num1'].value", Collections.emptyMap()))
+ .addScriptField("date1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['date'].date.millis", Collections.emptyMap()))
.execute().actionGet();
assertNoFailures(response);
@@ -321,7 +324,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
response = client().prepareSearch()
.setQuery(matchAllQuery())
.addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", new Script("doc['num1'].value * factor", ScriptType.INLINE, CustomScriptPlugin.NAME, params))
+ .addScriptField("sNum1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value * factor", params))
.get();
assertThat(response.getHits().totalHits(), equalTo(3L));
@@ -357,7 +360,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
.setQuery(matchAllQuery())
.addSort("num1", SortOrder.ASC)
.setSize(numDocs)
- .addScriptField("uid", new Script("_fields._uid.value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("uid", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._uid.value", Collections.emptyMap()))
.get();
assertNoFailures(response);
@@ -375,7 +378,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
.setQuery(matchAllQuery())
.addSort("num1", SortOrder.ASC)
.setSize(numDocs)
- .addScriptField("id", new Script("_fields._id.value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._id.value", Collections.emptyMap()))
.get();
assertNoFailures(response);
@@ -393,7 +396,8 @@ public class SearchFieldsIT extends ESIntegTestCase {
.setQuery(matchAllQuery())
.addSort("num1", SortOrder.ASC)
.setSize(numDocs)
- .addScriptField("type", new Script("_fields._type.value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("type",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._type.value", Collections.emptyMap()))
.get();
assertNoFailures(response);
@@ -411,9 +415,10 @@ public class SearchFieldsIT extends ESIntegTestCase {
.setQuery(matchAllQuery())
.addSort("num1", SortOrder.ASC)
.setSize(numDocs)
- .addScriptField("id", new Script("_fields._id.value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("uid", new Script("_fields._uid.value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("type", new Script("_fields._type.value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._id.value", Collections.emptyMap()))
+ .addScriptField("uid", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._uid.value", Collections.emptyMap()))
+ .addScriptField("type",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_fields._type.value", Collections.emptyMap()))
.get();
assertNoFailures(response);
@@ -444,11 +449,13 @@ public class SearchFieldsIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("s_obj1", new Script("_source.obj1", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("s_obj1_test", new Script("_source.obj1.test", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("s_obj2", new Script("_source.obj2", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("s_obj2_arr2", new Script("_source.obj2.arr2", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
- .addScriptField("s_arr3", new Script("_source.arr3", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("s_obj1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.obj1", Collections.emptyMap()))
+ .addScriptField("s_obj1_test",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.obj1.test", Collections.emptyMap()))
+ .addScriptField("s_obj2", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.obj2", Collections.emptyMap()))
+ .addScriptField("s_obj2_arr2",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.obj2.arr2", Collections.emptyMap()))
+ .addScriptField("s_arr3", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.arr3", Collections.emptyMap()))
.get();
assertThat("Failures " + Arrays.toString(response.getShardFailures()), response.getShardFailures().length, equalTo(0));
@@ -481,7 +488,8 @@ public class SearchFieldsIT extends ESIntegTestCase {
SearchResponse response = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("test_script_1", new Script("return null", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("test_script_1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return null", Collections.emptyMap()))
.get();
assertNoFailures(response);
@@ -847,7 +855,8 @@ public class SearchFieldsIT extends ESIntegTestCase {
ensureSearchable();
SearchRequestBuilder req = client().prepareSearch("index");
for (String field : Arrays.asList("s", "ms", "l", "ml", "d", "md")) {
- req.addScriptField(field, new Script("doc['" + field + "'].values", ScriptType.INLINE, CustomScriptPlugin.NAME, null));
+ req.addScriptField(field,
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['" + field + "'].values", Collections.emptyMap()));
}
SearchResponse resp = req.get();
assertSearchResponse(resp);
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java
index dacd11c843..9b732bdc00 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java
@@ -44,6 +44,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@@ -76,7 +77,8 @@ public class ExplainableScriptIT extends ESIntegTestCase {
SearchResponse response = client().search(searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
searchSource().explain(true).query(
functionScoreQuery(termQuery("text", "text"),
- scriptFunction(new Script("native_explainable_script", ScriptType.INLINE, "native", null)))
+ scriptFunction(
+ new Script(ScriptType.INLINE, "native", "native_explainable_script", Collections.emptyMap())))
.boostMode(CombineFunction.REPLACE)))).actionGet();
ElasticsearchAssertions.assertNoFailures(response);
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java
index 2bd6de9e64..e9cb9d72a8 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java
@@ -94,8 +94,8 @@ public class FunctionScoreIT extends ESIntegTestCase {
index(INDEX, TYPE, "1", jsonBuilder().startObject().field("dummy_field", 1).endObject());
refresh();
- Script scriptOne = new Script("1", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
- Script scriptTwo = new Script("get score value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script scriptOne = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "1", Collections.emptyMap());
+ Script scriptTwo = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get score value", Collections.emptyMap());
SearchResponse response = client().search(
searchRequest().source(
@@ -118,7 +118,7 @@ public class FunctionScoreIT extends ESIntegTestCase {
index(INDEX, TYPE, "1", jsonBuilder().startObject().field("dummy_field", 1).endObject());
refresh();
- Script script = new Script("get score value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get score value", Collections.emptyMap());
SearchResponse response = client().search(
searchRequest().source(
@@ -146,7 +146,7 @@ public class FunctionScoreIT extends ESIntegTestCase {
refresh();
ensureYellow();
- Script script = new Script("doc['random_score']", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['random_score']", Collections.emptyMap());
SearchResponse searchResponse = client().search(
searchRequest().source(searchSource().query(functionScoreQuery(scriptFunction(script)).setMinScore(minScore)))
).actionGet();
@@ -178,7 +178,7 @@ public class FunctionScoreIT extends ESIntegTestCase {
docs.add(client().prepareIndex(INDEX, TYPE, Integer.toString(i)).setSource("num", i + scoreOffset));
}
indexRandom(true, docs);
- Script script = new Script("return (doc['num'].value)", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return (doc['num'].value)", Collections.emptyMap());
int numMatchingDocs = numDocs + scoreOffset - minScore;
if (numMatchingDocs < 0) {
numMatchingDocs = 0;
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java
index cd28360550..a6f7eb760d 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java
@@ -169,7 +169,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
params.put("factor", randomIntBetween(2, 4));
// Test for accessing _score
- Script script = new Script("log(doc['index'].value + (factor * _score))", ScriptType.INLINE, NAME, params);
+ Script script = new Script(ScriptType.INLINE, NAME, "log(doc['index'].value + (factor * _score))", params);
SearchResponse resp = client()
.prepareSearch("test")
.setQuery(
@@ -185,7 +185,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
assertThat(firstHit.getScore(), greaterThan(1f));
// Test for accessing _score.intValue()
- script = new Script("log(doc['index'].value + (factor * _score.intValue()))", ScriptType.INLINE, NAME, params);
+ script = new Script(ScriptType.INLINE, NAME, "log(doc['index'].value + (factor * _score.intValue()))", params);
resp = client()
.prepareSearch("test")
.setQuery(
@@ -201,7 +201,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
assertThat(firstHit.getScore(), greaterThan(1f));
// Test for accessing _score.longValue()
- script = new Script("log(doc['index'].value + (factor * _score.longValue()))", ScriptType.INLINE, NAME, params);
+ script = new Script(ScriptType.INLINE, NAME, "log(doc['index'].value + (factor * _score.longValue()))", params);
resp = client()
.prepareSearch("test")
.setQuery(
@@ -217,7 +217,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
assertThat(firstHit.getScore(), greaterThan(1f));
// Test for accessing _score.floatValue()
- script = new Script("log(doc['index'].value + (factor * _score.floatValue()))", ScriptType.INLINE, NAME, params);
+ script = new Script(ScriptType.INLINE, NAME, "log(doc['index'].value + (factor * _score.floatValue()))", params);
resp = client()
.prepareSearch("test")
.setQuery(
@@ -233,7 +233,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
assertThat(firstHit.getScore(), greaterThan(1f));
// Test for accessing _score.doubleValue()
- script = new Script("log(doc['index'].value + (factor * _score.doubleValue()))", ScriptType.INLINE, NAME, params);
+ script = new Script(ScriptType.INLINE, NAME, "log(doc['index'].value + (factor * _score.doubleValue()))", params);
resp = client()
.prepareSearch("test")
.setQuery(
diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoDistanceIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoDistanceIT.java
index 841b6bcd98..6c9acd7e8a 100644
--- a/core/src/test/java/org/elasticsearch/search/geo/GeoDistanceIT.java
+++ b/core/src/test/java/org/elasticsearch/search/geo/GeoDistanceIT.java
@@ -48,6 +48,7 @@ import org.junit.Before;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -127,7 +128,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
// Test doc['location'].arcDistance(lat, lon)
SearchResponse searchResponse1 = client().prepareSearch().addStoredField("_source")
- .addScriptField("distance", new Script("arcDistance", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance", Collections.emptyMap()))
.get();
Double resultDistance1 = searchResponse1.getHits().getHits()[0].getFields().get("distance").getValue();
assertThat(resultDistance1,
@@ -135,16 +136,16 @@ public class GeoDistanceIT extends ESIntegTestCase {
// Test doc['location'].planeDistance(lat, lon)
SearchResponse searchResponse2 = client().prepareSearch().addStoredField("_source")
- .addScriptField("distance", new Script("planeDistance", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null)).get();
+ .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "planeDistance",
+ Collections.emptyMap())).get();
Double resultDistance2 = searchResponse2.getHits().getHits()[0].getFields().get("distance").getValue();
assertThat(resultDistance2,
closeTo(GeoUtils.planeDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
// Test doc['location'].geohashDistance(lat, lon)
SearchResponse searchResponse4 = client().prepareSearch().addStoredField("_source")
- .addScriptField("distance", new Script("geohashDistance", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null)).get();
+ .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "geohashDistance",
+ Collections.emptyMap())).get();
Double resultDistance4 = searchResponse4.getHits().getHits()[0].getFields().get("distance").getValue();
assertThat(resultDistance4,
closeTo(GeoUtils.arcDistance(src_lat, src_lon, GeoHashUtils.decodeLatitude(tgt_geohash),
@@ -152,16 +153,16 @@ public class GeoDistanceIT extends ESIntegTestCase {
// Test doc['location'].arcDistance(lat, lon + 360)/1000d
SearchResponse searchResponse5 = client().prepareSearch().addStoredField("_source")
- .addScriptField("distance", new Script("arcDistance(lat, lon + 360)/1000d", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null)).get();
+ .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat, lon + 360)/1000d",
+ Collections.emptyMap())).get();
Double resultArcDistance5 = searchResponse5.getHits().getHits()[0].getFields().get("distance").getValue();
assertThat(resultArcDistance5,
closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon)/1000d, 0.01d));
// Test doc['location'].arcDistance(lat + 360, lon)/1000d
SearchResponse searchResponse6 = client().prepareSearch().addStoredField("_source")
- .addScriptField("distance", new Script("arcDistance(lat + 360, lon)/1000d", ScriptType.INLINE,
- CustomScriptPlugin.NAME, null)).get();
+ .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat + 360, lon)/1000d",
+ Collections.emptyMap())).get();
Double resultArcDistance6 = searchResponse6.getHits().getHits()[0].getFields().get("distance").getValue();
assertThat(resultArcDistance6,
closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon)/1000d, 0.01d));
diff --git a/core/src/test/java/org/elasticsearch/search/scriptfilter/ScriptQuerySearchIT.java b/core/src/test/java/org/elasticsearch/search/scriptfilter/ScriptQuerySearchIT.java
index f01f6d5d0e..02fde4d971 100644
--- a/core/src/test/java/org/elasticsearch/search/scriptfilter/ScriptQuerySearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/scriptfilter/ScriptQuerySearchIT.java
@@ -104,9 +104,11 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
logger.info("running doc['num1'].value > 1");
SearchResponse response = client().prepareSearch()
- .setQuery(scriptQuery(new Script("doc['num1'].value > 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .setQuery(scriptQuery(
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > 1", Collections.emptyMap())))
.addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", new Script("doc['num1'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("sNum1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
.get();
assertThat(response.getHits().totalHits(), equalTo(2L));
@@ -121,9 +123,10 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
logger.info("running doc['num1'].value > param1");
response = client()
.prepareSearch()
- .setQuery(scriptQuery(new Script("doc['num1'].value > param1", ScriptType.INLINE, CustomScriptPlugin.NAME, params)))
+ .setQuery(scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > param1", params)))
.addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", new Script("doc['num1'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("sNum1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
.get();
assertThat(response.getHits().totalHits(), equalTo(1L));
@@ -135,9 +138,10 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
logger.info("running doc['num1'].value > param1");
response = client()
.prepareSearch()
- .setQuery(scriptQuery(new Script("doc['num1'].value > param1", ScriptType.INLINE, CustomScriptPlugin.NAME, params)))
+ .setQuery(scriptQuery(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value > param1", params)))
.addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", new Script("doc['num1'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("sNum1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['num1'].value", Collections.emptyMap()))
.get();
assertThat(response.getHits().totalHits(), equalTo(3L));
diff --git a/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java
index 5146660aa0..d6f96c4c58 100644
--- a/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java
@@ -31,6 +31,7 @@ import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.sort.ScriptSortBuilder.ScriptSortType;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -76,7 +77,7 @@ public class ScriptSortBuilderTests extends AbstractSortTestCase<ScriptSortBuild
Script script = original.script();
ScriptSortType type = original.type();
if (randomBoolean()) {
- result = new ScriptSortBuilder(new Script(script.getScript() + "_suffix"), type);
+ result = new ScriptSortBuilder(new Script(script.getIdOrCode() + "_suffix"), type);
} else {
result = new ScriptSortBuilder(script, type.equals(ScriptSortType.NUMBER) ? ScriptSortType.STRING : ScriptSortType.NUMBER);
}
@@ -173,7 +174,7 @@ public class ScriptSortBuilderTests extends AbstractSortTestCase<ScriptSortBuild
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry, parser, ParseFieldMatcher.STRICT);
ScriptSortBuilder builder = ScriptSortBuilder.fromXContent(context, null);
- assertEquals("doc['field_name'].value * factor", builder.script().getScript());
+ assertEquals("doc['field_name'].value * factor", builder.script().getIdOrCode());
assertEquals(Script.DEFAULT_SCRIPT_LANG, builder.script().getLang());
assertEquals(1.1, builder.script().getParams().get("factor"));
assertEquals(ScriptType.INLINE, builder.script().getType());
@@ -199,9 +200,9 @@ public class ScriptSortBuilderTests extends AbstractSortTestCase<ScriptSortBuild
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry, parser, ParseFieldMatcher.STRICT);
ScriptSortBuilder builder = ScriptSortBuilder.fromXContent(context, null);
- assertEquals("doc['field_name'].value", builder.script().getScript());
+ assertEquals("doc['field_name'].value", builder.script().getIdOrCode());
assertEquals(Script.DEFAULT_SCRIPT_LANG, builder.script().getLang());
- assertNull(builder.script().getParams());
+ assertEquals(builder.script().getParams(), Collections.emptyMap());
assertEquals(ScriptType.INLINE, builder.script().getType());
assertEquals(ScriptSortType.NUMBER, builder.type());
assertEquals(SortOrder.ASC, builder.order());
diff --git a/core/src/test/java/org/elasticsearch/search/sort/SimpleSortIT.java b/core/src/test/java/org/elasticsearch/search/sort/SimpleSortIT.java
index 92dd133b24..d73da7e507 100644
--- a/core/src/test/java/org/elasticsearch/search/sort/SimpleSortIT.java
+++ b/core/src/test/java/org/elasticsearch/search/sort/SimpleSortIT.java
@@ -183,7 +183,7 @@ public class SimpleSortIT extends ESIntegTestCase {
// STRING script
int size = 1 + random.nextInt(10);
- Script script = new Script("doc['str_value'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_value'].value", Collections.emptyMap());
SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
@@ -275,7 +275,7 @@ public class SimpleSortIT extends ESIntegTestCase {
// test the long values
SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("min", new Script("get min long", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min long", Collections.emptyMap()))
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
.setSize(10)
.get();
@@ -291,7 +291,7 @@ public class SimpleSortIT extends ESIntegTestCase {
// test the double values
searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("min", new Script("get min double", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min double", Collections.emptyMap()))
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
.setSize(10)
.get();
@@ -307,7 +307,7 @@ public class SimpleSortIT extends ESIntegTestCase {
// test the string values
searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("min", new Script("get min string", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("min", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min string", Collections.emptyMap()))
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
.setSize(10)
.get();
@@ -323,7 +323,8 @@ public class SimpleSortIT extends ESIntegTestCase {
// test the geopoint values
searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("min", new Script("get min geopoint lon", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("min",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get min geopoint lon", Collections.emptyMap()))
.addSort(SortBuilders.fieldSort("ord").order(SortOrder.ASC).unmappedType("long"))
.setSize(10)
.get();
@@ -381,7 +382,7 @@ public class SimpleSortIT extends ESIntegTestCase {
flush();
refresh();
- Script scripField = new Script("doc['id'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script scripField = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['id'].value", Collections.emptyMap());
SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
@@ -398,7 +399,7 @@ public class SimpleSortIT extends ESIntegTestCase {
searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
- .addScriptField("id", new Script("doc['id'].values[0]", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("id", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['id'].values[0]", Collections.emptyMap()))
.addSort("svalue", SortOrder.ASC)
.get();
@@ -466,7 +467,7 @@ public class SimpleSortIT extends ESIntegTestCase {
}
refresh();
- Script sortScript = new Script("\u0027\u0027", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ Script sortScript = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "\u0027\u0027", Collections.emptyMap());
SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
.addSort(scriptSort(sortScript, ScriptSortType.STRING))
diff --git a/core/src/test/java/org/elasticsearch/search/stats/SearchStatsIT.java b/core/src/test/java/org/elasticsearch/search/stats/SearchStatsIT.java
index 9cc9811358..83fb38f18a 100644
--- a/core/src/test/java/org/elasticsearch/search/stats/SearchStatsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/stats/SearchStatsIT.java
@@ -121,7 +121,8 @@ public class SearchStatsIT extends ESIntegTestCase {
SearchResponse searchResponse = internalCluster().coordOnlyNodeClient().prepareSearch()
.setQuery(QueryBuilders.termQuery("field", "value")).setStats("group1", "group2")
.highlighter(new HighlightBuilder().field("field"))
- .addScriptField("script1", new Script("_source.field", ScriptType.INLINE, CustomScriptPlugin.NAME, null))
+ .addScriptField("script1",
+ new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_source.field", Collections.emptyMap()))
.setSize(100)
.execute().actionGet();
assertHitCount(searchResponse, docsTest1 + docsTest2);
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilderTests.java b/core/src/test/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilderTests.java
index 4c5b3b8ca6..eab8440fa8 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilderTests.java
@@ -111,7 +111,7 @@ public class PhraseSuggestionBuilderTests extends AbstractSuggestionBuilderTestC
case 6:
Script collateQuery = builder.collateQuery();
if (collateQuery != null) {
- builder.collateQuery(randomValueOtherThan(collateQuery.getScript(), () -> randomAsciiOfLengthBetween(3, 20)));
+ builder.collateQuery(randomValueOtherThan(collateQuery.getIdOrCode(), () -> randomAsciiOfLengthBetween(3, 20)));
} else {
builder.collateQuery(randomAsciiOfLengthBetween(3, 20));
}