summaryrefslogtreecommitdiff
path: root/core/src/test/java
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
parent2e531902ffb776e6ea9d15e99ab904aa4cb256dc (diff)
Clean up of Script.
Closes #21321
Diffstat (limited to 'core/src/test/java')
-rw-r--r--core/src/test/java/org/elasticsearch/VersionTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java17
-rw-r--r--core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java20
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java27
-rw-r--r--core/src/test/java/org/elasticsearch/index/WaitUntilRefreshIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/script/FileScriptTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/script/IndexLookupIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/script/NativeScriptTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptContextTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java9
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java43
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptTests.java13
-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
-rw-r--r--core/src/test/java/org/elasticsearch/update/TimestampTTLBWIT.java16
-rw-r--r--core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/update/UpdateIT.java56
67 files changed, 557 insertions, 432 deletions
diff --git a/core/src/test/java/org/elasticsearch/VersionTests.java b/core/src/test/java/org/elasticsearch/VersionTests.java
index 167a36a96d..5e4e3812fc 100644
--- a/core/src/test/java/org/elasticsearch/VersionTests.java
+++ b/core/src/test/java/org/elasticsearch/VersionTests.java
@@ -26,6 +26,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.monitor.os.OsStats;
import org.elasticsearch.index.query.SimpleQueryStringBuilder;
+import org.elasticsearch.script.Script;
import org.elasticsearch.search.internal.AliasFilter;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
@@ -278,6 +279,8 @@ public class VersionTests extends ESTestCase {
assertUnknownVersion(SimpleQueryStringBuilder.V_5_1_0_UNRELEASED);
assertUnknownVersion(QueryStringQueryBuilder.V_5_1_0_UNRELEASED);
// once we released 5.0.0 and it's added to Version.java we need to remove this constant
+ assertUnknownVersion(Script.V_5_1_0_UNRELEASED);
+ // once we released 5.0.0 and it's added to Version.java we need to remove this constant
}
public static void assertUnknownVersion(Version version) {
diff --git a/core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java b/core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java
index 75ba6f2b11..e4a6eef33e 100644
--- a/core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java
+++ b/core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java
@@ -259,7 +259,7 @@ public class IndicesRequestIT extends ESIntegTestCase {
String indexOrAlias = randomIndexOrAlias();
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id")
- .script(new Script("ctx.op='delete'", ScriptType.INLINE, CustomScriptPlugin.NAME, Collections.emptyMap()));
+ .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op='delete'", Collections.emptyMap()));
UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet();
assertEquals(DocWriteResponse.Result.DELETED, updateResponse.getResult());
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
index 57aa0cbb9a..a4a5f6f5ba 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
@@ -89,7 +89,7 @@ public class BulkRequestTests extends ESTestCase {
assertThat(((UpdateRequest) bulkRequest.requests().get(1)).index(), equalTo("index1"));
Script script = ((UpdateRequest) bulkRequest.requests().get(1)).script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("counter += param1"));
+ assertThat(script.getIdOrCode(), equalTo("counter += param1"));
assertThat(script.getLang(), equalTo("javascript"));
Map<String, Object> scriptParams = script.getParams();
assertThat(scriptParams, notNullValue());
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java
index 28b52eca31..82eee3554e 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java
@@ -122,7 +122,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
}
- final Script script = new Script("ctx._source.field += 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ final Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx._source.field += 1", Collections.emptyMap());
bulkResponse = client().prepareBulk()
.add(client().prepareUpdate().setIndex(indexOrAlias()).setType("type1").setId("1").setScript(script))
@@ -259,11 +259,14 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
bulkResponse = client().prepareBulk()
.add(client().prepareUpdate().setIndex("test").setType("type1").setId("1").setFields("field")
- .setScript(new Script("throw script exception on unknown var", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .setScript(new Script(
+ ScriptType.INLINE, CustomScriptPlugin.NAME, "throw script exception on unknown var", Collections.emptyMap())))
.add(client().prepareUpdate().setIndex("test").setType("type1").setId("2").setFields("field")
- .setScript(new Script("ctx._source.field += 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .setScript(new Script(
+ ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx._source.field += 1", Collections.emptyMap())))
.add(client().prepareUpdate().setIndex("test").setType("type1").setId("3").setFields("field")
- .setScript(new Script("throw script exception on unknown var", ScriptType.INLINE, CustomScriptPlugin.NAME, null)))
+ .setScript(new Script(
+ ScriptType.INLINE, CustomScriptPlugin.NAME, "throw script exception on unknown var", Collections.emptyMap())))
.execute().actionGet();
assertThat(bulkResponse.hasFailures(), equalTo(true));
@@ -291,7 +294,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
numDocs++; // this test needs an even num of docs
}
- final Script script = new Script("ctx._source.counter += 1", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ final Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx._source.counter += 1", Collections.emptyMap());
BulkRequestBuilder builder = client().prepareBulk();
for (int i = 0; i < numDocs; i++) {
@@ -380,7 +383,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
builder = client().prepareBulk();
for (int i = 0; i < numDocs; i++) {
builder.add(client().prepareUpdate().setIndex("test").setType("type1").setId(Integer.toString(i))
- .setScript(new Script("ctx.op = \"none\"", ScriptType.INLINE, CustomScriptPlugin.NAME, null)));
+ .setScript(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op = \"none\"", Collections.emptyMap())));
}
response = builder.execute().actionGet();
assertThat(response.buildFailureMessage(), response.hasFailures(), equalTo(false));
@@ -396,7 +399,7 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
builder = client().prepareBulk();
for (int i = 0; i < numDocs; i++) {
builder.add(client().prepareUpdate().setIndex("test").setType("type1").setId(Integer.toString(i))
- .setScript(new Script("ctx.op = \"delete\"", ScriptType.INLINE, CustomScriptPlugin.NAME, null)));
+ .setScript(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op = \"delete\"", Collections.emptyMap())));
}
response = builder.execute().actionGet();
assertThat(response.hasFailures(), equalTo(false));
diff --git a/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java b/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java
index 942849bd17..3b27bbff9c 100644
--- a/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java
@@ -65,11 +65,11 @@ public class UpdateRequestTests extends ESTestCase {
.endObject());
Script script = request.script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("script1"));
+ assertThat(script.getIdOrCode(), equalTo("script1"));
assertThat(script.getType(), equalTo(ScriptType.INLINE));
assertThat(script.getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
Map<String, Object> params = script.getParams();
- assertThat(params, nullValue());
+ assertThat(params, equalTo(Collections.emptyMap()));
// simple verbose script
request.fromXContent(XContentFactory.jsonBuilder().startObject()
@@ -77,11 +77,11 @@ public class UpdateRequestTests extends ESTestCase {
.endObject());
script = request.script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("script1"));
+ assertThat(script.getIdOrCode(), equalTo("script1"));
assertThat(script.getType(), equalTo(ScriptType.INLINE));
assertThat(script.getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
params = script.getParams();
- assertThat(params, nullValue());
+ assertThat(params, equalTo(Collections.emptyMap()));
// script with params
request = new UpdateRequest("test", "type", "1");
@@ -94,7 +94,7 @@ public class UpdateRequestTests extends ESTestCase {
.endObject().endObject());
script = request.script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("script1"));
+ assertThat(script.getIdOrCode(), equalTo("script1"));
assertThat(script.getType(), equalTo(ScriptType.INLINE));
assertThat(script.getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
params = script.getParams();
@@ -108,7 +108,7 @@ public class UpdateRequestTests extends ESTestCase {
.field("inline", "script1").endObject().endObject());
script = request.script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("script1"));
+ assertThat(script.getIdOrCode(), equalTo("script1"));
assertThat(script.getType(), equalTo(ScriptType.INLINE));
assertThat(script.getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
params = script.getParams();
@@ -133,7 +133,7 @@ public class UpdateRequestTests extends ESTestCase {
.endObject().endObject());
script = request.script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("script1"));
+ assertThat(script.getIdOrCode(), equalTo("script1"));
assertThat(script.getType(), equalTo(ScriptType.INLINE));
assertThat(script.getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
params = script.getParams();
@@ -160,7 +160,7 @@ public class UpdateRequestTests extends ESTestCase {
.endObject().endObject());
script = request.script();
assertThat(script, notNullValue());
- assertThat(script.getScript(), equalTo("script1"));
+ assertThat(script.getIdOrCode(), equalTo("script1"));
assertThat(script.getType(), equalTo(ScriptType.INLINE));
assertThat(script.getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
params = script.getParams();
@@ -325,7 +325,7 @@ public class UpdateRequestTests extends ESTestCase {
{
UpdateRequest updateRequest = new UpdateRequest("test", "type1", "2")
.upsert(indexRequest)
- .script(new Script("ctx._source.update_timestamp = ctx._now", ScriptType.INLINE, "mock", Collections.emptyMap()))
+ .script(new Script(ScriptType.INLINE, "mock", "ctx._source.update_timestamp = ctx._now", Collections.emptyMap()))
.scriptedUpsert(true);
long nowInMillis = randomPositiveLong();
// We simulate that the document is not existing yet
@@ -339,7 +339,7 @@ public class UpdateRequestTests extends ESTestCase {
{
UpdateRequest updateRequest = new UpdateRequest("test", "type1", "2")
.upsert(indexRequest)
- .script(new Script("ctx._timestamp = ctx._now", ScriptType.INLINE, "mock", Collections.emptyMap()))
+ .script(new Script(ScriptType.INLINE, "mock", "ctx._timestamp = ctx._now", Collections.emptyMap()))
.scriptedUpsert(true);
long nowInMillis = randomPositiveLong();
// We simulate that the document is not existing yet
diff --git a/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java
index fac8d5f7b6..f73043ce4e 100644
--- a/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java
@@ -40,6 +40,8 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
+import java.util.Collections;
+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
@@ -122,12 +124,14 @@ public class NoMasterNodeIT extends ESIntegTestCase {
checkWriteAction(
false, timeout,
client().prepareUpdate("test", "type1", "1")
- .setScript(new Script("test script", ScriptType.INLINE, null, null)).setTimeout(timeout));
+ .setScript(new Script(
+ ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "test script", Collections.emptyMap())).setTimeout(timeout));
checkWriteAction(
autoCreateIndex, timeout,
client().prepareUpdate("no_index", "type1", "1")
- .setScript(new Script("test script", ScriptType.INLINE, null, null)).setTimeout(timeout));
+ .setScript(new Script(
+ ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "test script", Collections.emptyMap())).setTimeout(timeout));
checkWriteAction(false, timeout,
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java
index cce349f417..cbcff431c2 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java
@@ -24,6 +24,7 @@ import org.elasticsearch.test.ESTestCase;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
@@ -75,4 +76,30 @@ public class XContentParserTests extends ESTestCase {
assertThat(e.getMessage(), containsString("Failed to parse list"));
}
}
+
+ public void testReadMapStrings() throws IOException {
+ Map<String, String> map = readMapStrings("{\"foo\": {\"kbar\":\"vbar\"}}");
+ assertThat(map.get("kbar"), equalTo("vbar"));
+ assertThat(map.size(), equalTo(1));
+ map = readMapStrings("{\"foo\": {\"kbar\":\"vbar\", \"kbaz\":\"vbaz\"}}");
+ assertThat(map.get("kbar"), equalTo("vbar"));
+ assertThat(map.get("kbaz"), equalTo("vbaz"));
+ assertThat(map.size(), equalTo(2));
+ map = readMapStrings("{\"foo\": {}}");
+ assertThat(map.size(), equalTo(0));
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Map<String, String> readMapStrings(String source) throws IOException {
+ try (XContentParser parser = XContentType.JSON.xContent().createParser(source)) {
+ XContentParser.Token token = parser.nextToken();
+ assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
+ token = parser.nextToken();
+ assertThat(token, equalTo(XContentParser.Token.FIELD_NAME));
+ assertThat(parser.currentName(), equalTo("foo"));
+ token = parser.nextToken();
+ assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
+ return randomBoolean() ? parser.mapStringsOrdered() : parser.mapStrings();
+ }
+ }
}
diff --git a/core/src/test/java/org/elasticsearch/index/WaitUntilRefreshIT.java b/core/src/test/java/org/elasticsearch/index/WaitUntilRefreshIT.java
index cc9f910874..0f72e72f6a 100644
--- a/core/src/test/java/org/elasticsearch/index/WaitUntilRefreshIT.java
+++ b/core/src/test/java/org/elasticsearch/index/WaitUntilRefreshIT.java
@@ -109,7 +109,7 @@ public class WaitUntilRefreshIT extends ESIntegTestCase {
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "cat")).get(), "2");
// Update-becomes-delete with RefreshPolicy.WAIT_UNTIL
- update = client().prepareUpdate("test", "test", "2").setScript(new Script("delete_plz", ScriptType.INLINE, "native", emptyMap()))
+ update = client().prepareUpdate("test", "test", "2").setScript(new Script(ScriptType.INLINE, "native", "delete_plz", emptyMap()))
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL).get();
assertEquals(2, update.getVersion());
assertFalse("request shouldn't have forced a refresh", update.forcedRefresh());
diff --git a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java
index 607415d762..2e1f70ab5f 100644
--- a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java
@@ -320,15 +320,14 @@ public class InnerHitBuilderTests extends ESTestCase {
static SearchSourceBuilder.ScriptField randomScript() {
ScriptType randomScriptType = randomFrom(ScriptType.values());
- Map<String, Object> randomMap = null;
+ Map<String, Object> randomMap = new HashMap<>();
if (randomBoolean()) {
- randomMap = new HashMap<>();
int numEntries = randomIntBetween(0, 32);
for (int i = 0; i < numEntries; i++) {
randomMap.put(String.valueOf(i), randomAsciiOfLength(16));
}
}
- Script script = new Script(randomAsciiOfLength(128), randomScriptType, randomAsciiOfLengthBetween(1, 4),randomMap);
+ Script script = new Script(randomScriptType, randomAsciiOfLengthBetween(1, 4), randomAsciiOfLength(128), randomMap);
return new SearchSourceBuilder.ScriptField(randomAsciiOfLengthBetween(1, 32), script, randomBoolean());
}
diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java
index 3e1e74e8eb..97adfad95d 100644
--- a/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/QueryDSLDocumentationTests.java
@@ -293,13 +293,11 @@ public class QueryDSLDocumentationTests extends ESTestCase {
new Script("doc['num1'].value > 1")
);
- Map<String, Integer> parameters = new HashMap<>();
+ Map<String, Object> parameters = new HashMap<>();
parameters.put("param1", 5);
scriptQuery(
new Script(
- "mygroovyscript",
- ScriptType.FILE,
- "groovy",
+ ScriptType.FILE, "groovy", "mygroovyscript",
parameters)
);
diff --git a/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java
index 1eb2b23dce..3be16e27c4 100644
--- a/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/ScriptQueryBuilderTests.java
@@ -39,7 +39,7 @@ public class ScriptQueryBuilderTests extends AbstractQueryTestCase<ScriptQueryBu
protected ScriptQueryBuilder doCreateTestQueryBuilder() {
String script = "1";
Map<String, Object> params = Collections.emptyMap();
- return new ScriptQueryBuilder(new Script(script, ScriptType.INLINE, MockScriptEngine.NAME, params));
+ return new ScriptQueryBuilder(new Script(ScriptType.INLINE, MockScriptEngine.NAME, script, params));
}
@Override
@@ -67,8 +67,7 @@ public class ScriptQueryBuilderTests extends AbstractQueryTestCase<ScriptQueryBu
" \"script\" : {\n" +
" \"script\" : {\n" +
" \"inline\" : \"5\",\n" +
- " \"lang\" : \"mockscript\",\n" +
- " \"params\" : { }\n" +
+ " \"lang\" : \"mockscript\"\n" +
" },\n" +
" \"boost\" : 1.0,\n" +
" \"_name\" : \"PcKdEyPOmR\"\n" +
@@ -92,14 +91,14 @@ public class ScriptQueryBuilderTests extends AbstractQueryTestCase<ScriptQueryBu
"}";
ScriptQueryBuilder parsed = (ScriptQueryBuilder) parseQuery(json);
- assertEquals(json, "5", parsed.script().getScript());
+ assertEquals(json, "5", parsed.script().getIdOrCode());
}
@Override
protected Set<String> getObjectsHoldingArbitraryContent() {
//script_score.script.params can contain arbitrary parameters. no error is expected when
//adding additional objects within the params object.
- return Collections.singleton(Script.ScriptField.PARAMS.getPreferredName());
+ return Collections.singleton(Script.PARAMS_PARSE_FIELD.getPreferredName());
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java
index 50a7382e40..77edf2ed2f 100644
--- a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java
@@ -109,7 +109,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
protected Set<String> getObjectsHoldingArbitraryContent() {
//script_score.script.params can contain arbitrary parameters. no error is expected when adding additional objects
//within the params object. Score functions get parsed in the data nodes, so they are not validated in the coord node.
- return new HashSet<>(Arrays.asList(Script.ScriptField.PARAMS.getPreferredName(), ExponentialDecayFunctionBuilder.NAME,
+ return new HashSet<>(Arrays.asList(Script.PARAMS_PARSE_FIELD.getPreferredName(), ExponentialDecayFunctionBuilder.NAME,
LinearDecayFunctionBuilder.NAME, GaussDecayFunctionBuilder.NAME));
}
@@ -169,7 +169,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<Functi
String script = "1";
Map<String, Object> params = Collections.emptyMap();
functionBuilder = new ScriptScoreFunctionBuilder(
- new Script(script, ScriptType.INLINE, MockScriptEngine.NAME, params));
+ new Script(ScriptType.INLINE, MockScriptEngine.NAME, script, params));
break;
case 3:
RandomScoreFunctionBuilder randomScoreFunctionBuilder = new RandomScoreFunctionBuilderWithFixedSeed();
diff --git a/core/src/test/java/org/elasticsearch/script/FileScriptTests.java b/core/src/test/java/org/elasticsearch/script/FileScriptTests.java
index 58042fc768..f5ae13cf3a 100644
--- a/core/src/test/java/org/elasticsearch/script/FileScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/FileScriptTests.java
@@ -54,7 +54,7 @@ public class FileScriptTests extends ESTestCase {
Settings settings = Settings.builder()
.put("script.engine." + MockScriptEngine.NAME + ".file.aggs", "false").build();
ScriptService scriptService = makeScriptService(settings);
- Script script = new Script("script1", ScriptType.FILE, MockScriptEngine.NAME, null);
+ Script script = new Script(ScriptType.FILE, MockScriptEngine.NAME, "script1", Collections.emptyMap());
CompiledScript compiledScript = scriptService.compile(script, ScriptContext.Standard.SEARCH, Collections.emptyMap());
assertNotNull(compiledScript);
MockCompiledScript executable = (MockCompiledScript) compiledScript.compiled();
@@ -69,7 +69,7 @@ public class FileScriptTests extends ESTestCase {
.put("script.engine." + MockScriptEngine.NAME + ".file.update", "false")
.put("script.engine." + MockScriptEngine.NAME + ".file.ingest", "false").build();
ScriptService scriptService = makeScriptService(settings);
- Script script = new Script("script1", ScriptType.FILE, MockScriptEngine.NAME, null);
+ Script script = new Script(ScriptType.FILE, MockScriptEngine.NAME, "script1", Collections.emptyMap());
for (ScriptContext context : ScriptContext.Standard.values()) {
try {
scriptService.compile(script, context, Collections.emptyMap());
diff --git a/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java b/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java
index f45a6c01f8..f41d9d7c39 100644
--- a/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java
+++ b/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java
@@ -683,7 +683,7 @@ public class IndexLookupIT extends ESIntegTestCase {
}
private Script createScript(String script) {
- return new Script(script, ScriptType.INLINE, CustomScriptPlugin.NAME, null);
+ return new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, script, Collections.emptyMap());
}
public void testFlags() throws Exception {
diff --git a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
index efff2b0834..5423103f92 100644
--- a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
@@ -53,8 +53,7 @@ public class NativeScriptTests extends ESTestCase {
scriptSettings.add(InternalSettingsPlugin.VERSION_CREATED);
ExecutableScript executable = scriptModule.getScriptService().executable(
- new Script("my", ScriptType.INLINE, NativeScriptEngineService.NAME, null), ScriptContext.Standard.SEARCH,
- Collections.emptyMap());
+ new Script(ScriptType.INLINE, NativeScriptEngineService.NAME, "my", Collections.emptyMap()), ScriptContext.Standard.SEARCH);
assertThat(executable.run().toString(), equalTo("test"));
}
@@ -80,8 +79,8 @@ public class NativeScriptTests extends ESTestCase {
scriptContextRegistry, scriptSettings);
for (ScriptContext scriptContext : scriptContextRegistry.scriptContexts()) {
- assertThat(scriptService.compile(new Script("my", ScriptType.INLINE, NativeScriptEngineService.NAME, null), scriptContext,
- Collections.emptyMap()), notNullValue());
+ assertThat(scriptService.compile(new Script(ScriptType.INLINE, NativeScriptEngineService.NAME, "my", Collections.emptyMap()),
+ scriptContext, Collections.emptyMap()), notNullValue());
}
}
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java b/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java
index 8346f7fed3..9578e0c628 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java
@@ -58,7 +58,7 @@ public class ScriptContextTests extends ESTestCase {
ScriptService scriptService = makeScriptService();
for (ScriptType scriptType : ScriptType.values()) {
try {
- Script script = new Script("1", scriptType, MockScriptEngine.NAME, null);
+ Script script = new Script(scriptType, MockScriptEngine.NAME, "1", Collections.emptyMap());
scriptService.compile(script, new ScriptContext.Plugin(PLUGIN_NAME, "custom_globally_disabled_op"), Collections.emptyMap());
fail("script compilation should have been rejected");
} catch (IllegalStateException e) {
@@ -69,7 +69,7 @@ public class ScriptContextTests extends ESTestCase {
public void testCustomScriptContextSettings() throws Exception {
ScriptService scriptService = makeScriptService();
- Script script = new Script("1", ScriptType.INLINE, MockScriptEngine.NAME, null);
+ Script script = new Script(ScriptType.INLINE, MockScriptEngine.NAME, "1", Collections.emptyMap());
try {
scriptService.compile(script, new ScriptContext.Plugin(PLUGIN_NAME, "custom_exp_disabled_op"), Collections.emptyMap());
fail("script compilation should have been rejected");
@@ -87,7 +87,7 @@ public class ScriptContextTests extends ESTestCase {
ScriptService scriptService = makeScriptService();
for (ScriptType scriptType : ScriptType.values()) {
try {
- Script script = new Script("1", scriptType, MockScriptEngine.NAME, null);
+ Script script = new Script(scriptType, MockScriptEngine.NAME, "1", Collections.emptyMap());
scriptService.compile(script, new ScriptContext.Plugin(PLUGIN_NAME, "unknown"), Collections.emptyMap());
fail("script compilation should have been rejected");
} catch (IllegalArgumentException e) {
@@ -106,7 +106,7 @@ public class ScriptContextTests extends ESTestCase {
ScriptService scriptService = makeScriptService();
for (ScriptType scriptType : ScriptType.values()) {
try {
- Script script = new Script("1", scriptType, MockScriptEngine.NAME, null);
+ Script script = new Script(scriptType, MockScriptEngine.NAME, "1", Collections.emptyMap());
scriptService.compile(script, context, Collections.emptyMap());
fail("script compilation should have been rejected");
} catch (IllegalArgumentException e) {
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java b/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java
index b7aeb0db47..1a4a58e4b1 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java
@@ -31,6 +31,7 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
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;
@@ -60,10 +61,10 @@ public class ScriptFieldIT extends ESIntegTestCase {
client().admin().indices().prepareFlush("test").execute().actionGet();
SearchResponse sr = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery())
- .addScriptField("int", new Script("int", ScriptType.INLINE, "native", null))
- .addScriptField("float", new Script("float", ScriptType.INLINE, "native", null))
- .addScriptField("double", new Script("double", ScriptType.INLINE, "native", null))
- .addScriptField("long", new Script("long", ScriptType.INLINE, "native", null)).execute().actionGet();
+ .addScriptField("int", new Script(ScriptType.INLINE, "native", "int", Collections.emptyMap()))
+ .addScriptField("float", new Script(ScriptType.INLINE, "native", "float", Collections.emptyMap()))
+ .addScriptField("double", new Script(ScriptType.INLINE, "native", "double", Collections.emptyMap()))
+ .addScriptField("long", new Script(ScriptType.INLINE, "native", "long", Collections.emptyMap())).execute().actionGet();
assertThat(sr.getHits().hits().length, equalTo(6));
for (SearchHit hit : sr.getHits().getHits()) {
Object result = hit.getFields().get("int").getValues().get(0);
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java
index 2b14ba3f4d..73d3069cfa 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java
@@ -18,6 +18,7 @@
*/
package org.elasticsearch.script;
+import com.sun.javafx.collections.ElementObservableListDecorator;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
@@ -169,7 +170,7 @@ public class ScriptServiceTests extends ESTestCase {
Streams.copy("test_file".getBytes("UTF-8"), Files.newOutputStream(testFileWithExt));
resourceWatcherService.notifyNow();
- CompiledScript compiledScript = scriptService.compile(new Script("test_script", ScriptType.FILE, "test", null),
+ CompiledScript compiledScript = scriptService.compile(new Script(ScriptType.FILE, "test", "test_script", Collections.emptyMap()),
ScriptContext.Standard.SEARCH, Collections.emptyMap());
assertThat(compiledScript.compiled(), equalTo((Object) "compiled_test_file"));
@@ -178,7 +179,7 @@ public class ScriptServiceTests extends ESTestCase {
resourceWatcherService.notifyNow();
try {
- scriptService.compile(new Script("test_script", ScriptType.FILE, "test", null), ScriptContext.Standard.SEARCH,
+ scriptService.compile(new Script(ScriptType.FILE, "test", "test_script", Collections.emptyMap()), ScriptContext.Standard.SEARCH,
Collections.emptyMap());
fail("the script test_script should no longer exist");
} catch (IllegalArgumentException ex) {
@@ -196,7 +197,7 @@ public class ScriptServiceTests extends ESTestCase {
Streams.copy("test_file_script".getBytes("UTF-8"), Files.newOutputStream(testFileScript));
resourceWatcherService.notifyNow();
- CompiledScript compiledScript = scriptService.compile(new Script("file_script", ScriptType.FILE, "test", null),
+ CompiledScript compiledScript = scriptService.compile(new Script(ScriptType.FILE, "test", "file_script", Collections.emptyMap()),
ScriptContext.Standard.SEARCH, Collections.emptyMap());
assertThat(compiledScript.compiled(), equalTo((Object) "compiled_test_file_script"));
@@ -207,9 +208,9 @@ public class ScriptServiceTests extends ESTestCase {
public void testInlineScriptCompiledOnceCache() throws IOException {
buildScriptService(Settings.EMPTY);
- CompiledScript compiledScript1 = scriptService.compile(new Script("1+1", ScriptType.INLINE, "test", null),
+ CompiledScript compiledScript1 = scriptService.compile(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()),
randomFrom(scriptContexts), Collections.emptyMap());
- CompiledScript compiledScript2 = scriptService.compile(new Script("1+1", ScriptType.INLINE, "test", null),
+ CompiledScript compiledScript2 = scriptService.compile(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()),
randomFrom(scriptContexts), Collections.emptyMap());
assertThat(compiledScript1.compiled(), sameInstance(compiledScript2.compiled()));
}
@@ -332,8 +333,8 @@ public class ScriptServiceTests extends ESTestCase {
String type = scriptEngineService.getType();
try {
- scriptService.compile(new Script("test", randomFrom(ScriptType.values()), type, null), new ScriptContext.Plugin(
- pluginName, unknownContext), Collections.emptyMap());
+ scriptService.compile(new Script(randomFrom(ScriptType.values()), type, "test", Collections.emptyMap()),
+ new ScriptContext.Plugin(pluginName, unknownContext), Collections.emptyMap());
fail("script compilation should have been rejected");
} catch(IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("script context [" + pluginName + "_" + unknownContext + "] not supported"));
@@ -342,21 +343,20 @@ public class ScriptServiceTests extends ESTestCase {
public void testCompileCountedInCompilationStats() throws IOException {
buildScriptService(Settings.EMPTY);
- scriptService.compile(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts),
+ scriptService.compile(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts),
Collections.emptyMap());
assertEquals(1L, scriptService.stats().getCompilations());
}
public void testExecutableCountedInCompilationStats() throws IOException {
buildScriptService(Settings.EMPTY);
- scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), Collections.emptyMap());
+ scriptService.executable(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
assertEquals(1L, scriptService.stats().getCompilations());
}
public void testSearchCountedInCompilationStats() throws IOException {
buildScriptService(Settings.EMPTY);
- scriptService.search(null, new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts),
- Collections.emptyMap());
+ scriptService.search(null, new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
assertEquals(1L, scriptService.stats().getCompilations());
}
@@ -365,7 +365,7 @@ public class ScriptServiceTests extends ESTestCase {
int numberOfCompilations = randomIntBetween(1, 1024);
for (int i = 0; i < numberOfCompilations; i++) {
scriptService
- .compile(new Script(i + " + " + i, ScriptType.INLINE, "test", null), randomFrom(scriptContexts),
+ .compile(new Script(ScriptType.INLINE, "test", i + " + " + i, Collections.emptyMap()), randomFrom(scriptContexts),
Collections.emptyMap());
}
assertEquals(numberOfCompilations, scriptService.stats().getCompilations());
@@ -376,22 +376,22 @@ public class ScriptServiceTests extends ESTestCase {
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING.getKey(), 1);
builder.put("script.inline", "true");
buildScriptService(builder.build());
- scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), Collections.emptyMap());
- scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), Collections.emptyMap());
+ scriptService.executable(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
+ scriptService.executable(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
assertEquals(1L, scriptService.stats().getCompilations());
}
public void testFileScriptCountedInCompilationStats() throws IOException {
buildScriptService(Settings.EMPTY);
createFileScripts("test");
- scriptService.compile(new Script("file_script", ScriptType.FILE, "test", null), randomFrom(scriptContexts),
+ scriptService.compile(new Script(ScriptType.FILE, "test", "file_script", Collections.emptyMap()), randomFrom(scriptContexts),
Collections.emptyMap());
assertEquals(1L, scriptService.stats().getCompilations());
}
public void testIndexedScriptCountedInCompilationStats() throws IOException {
buildScriptService(Settings.EMPTY);
- scriptService.compile(new Script("script", ScriptType.STORED, "test", null), randomFrom(scriptContexts),
+ scriptService.compile(new Script(ScriptType.STORED, "test", "script", Collections.emptyMap()), randomFrom(scriptContexts),
Collections.emptyMap());
assertEquals(1L, scriptService.stats().getCompilations());
}
@@ -401,8 +401,8 @@ public class ScriptServiceTests extends ESTestCase {
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING.getKey(), 1);
builder.put("script.inline", "true");
buildScriptService(builder.build());
- scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), Collections.emptyMap());
- scriptService.executable(new Script("2+2", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), Collections.emptyMap());
+ scriptService.executable(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
+ scriptService.executable(new Script(ScriptType.INLINE, "test", "2+2", Collections.emptyMap()), randomFrom(scriptContexts));
assertEquals(2L, scriptService.stats().getCompilations());
assertEquals(1L, scriptService.stats().getCacheEvictions());
}
@@ -411,7 +411,8 @@ public class ScriptServiceTests extends ESTestCase {
Settings.Builder builder = Settings.builder();
builder.put("script.inline", "true");
buildScriptService(builder.build());
- CompiledScript script = scriptService.compile(new Script("1 + 1", ScriptType.INLINE, null, null),
+ CompiledScript script = scriptService.compile(
+ new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "1 + 1", Collections.emptyMap()),
randomFrom(scriptContexts), Collections.emptyMap());
assertEquals(script.lang(), Script.DEFAULT_SCRIPT_LANG);
}
@@ -493,7 +494,7 @@ public class ScriptServiceTests extends ESTestCase {
private void assertCompileRejected(String lang, String script, ScriptType scriptType, ScriptContext scriptContext) {
try {
- scriptService.compile(new Script(script, scriptType, lang, null), scriptContext, Collections.emptyMap());
+ scriptService.compile(new Script(scriptType, lang, script, Collections.emptyMap()), scriptContext, Collections.emptyMap());
fail("compile should have been rejected for lang [" + lang + "], script_type [" + scriptType + "], scripted_op [" + scriptContext + "]");
} catch(IllegalStateException e) {
//all good
@@ -502,7 +503,7 @@ public class ScriptServiceTests extends ESTestCase {
private void assertCompileAccepted(String lang, String script, ScriptType scriptType, ScriptContext scriptContext) {
assertThat(
- scriptService.compile(new Script(script, scriptType, lang, null), scriptContext, Collections.emptyMap()),
+ scriptService.compile(new Script(scriptType, lang, script, Collections.emptyMap()), scriptContext, Collections.emptyMap()),
notNullValue()
);
}
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptTests.java b/core/src/test/java/org/elasticsearch/script/ScriptTests.java
index c6424fdbdf..c1c25a500b 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptTests.java
@@ -65,7 +65,7 @@ public class ScriptTests extends ESTestCase {
}
private Script createScript(XContent xContent) throws IOException {
- final Map<String, Object> params = randomBoolean() ? null : Collections.singletonMap("key", "value");
+ final Map<String, Object> params = randomBoolean() ? Collections.emptyMap() : Collections.singletonMap("key", "value");
ScriptType scriptType = randomFrom(ScriptType.values());
String script;
if (scriptType == ScriptType.INLINE) {
@@ -79,11 +79,12 @@ public class ScriptTests extends ESTestCase {
script = randomAsciiOfLengthBetween(1, 5);
}
return new Script(
- script,
- scriptType,
- randomFrom("_lang1", "_lang2", null),
- params,
- scriptType == ScriptType.INLINE ? xContent.type() : null
+ scriptType,
+ randomFrom("_lang1", "_lang2", "_lang3"),
+ script,
+ scriptType == ScriptType.INLINE ?
+ Collections.singletonMap(Script.CONTENT_TYPE_OPTION, xContent.type().mediaType()) : Collections.emptyMap(),
+ params
);
}
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));
}
diff --git a/core/src/test/java/org/elasticsearch/update/TimestampTTLBWIT.java b/core/src/test/java/org/elasticsearch/update/TimestampTTLBWIT.java
index cdeec65844..39f1c77463 100644
--- a/core/src/test/java/org/elasticsearch/update/TimestampTTLBWIT.java
+++ b/core/src/test/java/org/elasticsearch/update/TimestampTTLBWIT.java
@@ -115,7 +115,7 @@ public class TimestampTTLBWIT extends ESIntegTestCase {
try {
client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null)).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap())).execute().actionGet();
fail();
} catch (DocumentMissingException e) {
// all is well
@@ -127,15 +127,15 @@ public class TimestampTTLBWIT extends ESIntegTestCase {
long ttl = ((Number) getResponse.getField("_ttl").getValue()).longValue();
assertThat(ttl, greaterThan(0L));
client().prepareUpdate(indexOrAlias(), "type1", "2")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null)).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap())).execute().actionGet();
getResponse = client().prepareGet("test", "type1", "2").setStoredFields("_ttl").execute().actionGet();
ttl = ((Number) getResponse.getField("_ttl").getValue()).longValue();
assertThat(ttl, greaterThan(0L));
// check TTL update
client().prepareUpdate(indexOrAlias(), "type1", "2")
- .setScript(new Script("", ScriptType.INLINE, "put_values",
- Collections.singletonMap("_ctx", Collections.singletonMap("_ttl", 3600000)))).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "put_values", "",
+ Collections.singletonMap("_ctx", Collections.singletonMap("_ttl", 3600000)))).execute().actionGet();
getResponse = client().prepareGet("test", "type1", "2").setStoredFields("_ttl").execute().actionGet();
ttl = ((Number) getResponse.getField("_ttl").getValue()).longValue();
assertThat(ttl, greaterThan(0L));
@@ -144,8 +144,8 @@ public class TimestampTTLBWIT extends ESIntegTestCase {
// check timestamp update
client().prepareIndex("test", "type1", "3").setSource("field", 1).setRefreshPolicy(IMMEDIATE).get();
client().prepareUpdate(indexOrAlias(), "type1", "3")
- .setScript(new Script("", ScriptType.INLINE, "put_values",
- Collections.singletonMap("_ctx", Collections.singletonMap("_timestamp", "2009-11-15T14:12:12")))).execute()
+ .setScript(new Script(ScriptType.INLINE, "put_values", "",
+ Collections.singletonMap("_ctx", Collections.singletonMap("_timestamp", "2009-11-15T14:12:12")))).execute()
.actionGet();
getResponse = client().prepareGet("test", "type1", "3").setStoredFields("_timestamp").execute().actionGet();
long timestamp = ((Number) getResponse.getField("_timestamp").getValue()).longValue();
@@ -198,7 +198,7 @@ public class TimestampTTLBWIT extends ESIntegTestCase {
// Update the first object and note context variables values
UpdateResponse updateResponse = client().prepareUpdate("test", "subtype1", "id1")
.setRouting("routing1")
- .setScript(new Script("", ScriptType.INLINE, "extract_ctx", null))
+ .setScript(new Script(ScriptType.INLINE, "extract_ctx", "", Collections.emptyMap()))
.execute().actionGet();
assertEquals(2, updateResponse.getVersion());
@@ -215,7 +215,7 @@ public class TimestampTTLBWIT extends ESIntegTestCase {
// Idem with the second object
updateResponse = client().prepareUpdate("test", "type1", "parentId1")
- .setScript(new Script("", ScriptType.INLINE, "extract_ctx", null))
+ .setScript(new Script(ScriptType.INLINE, "extract_ctx", "", Collections.emptyMap()))
.execute().actionGet();
assertEquals(2, updateResponse.getVersion());
diff --git a/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java b/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java
index bad89b7ab6..5982660845 100644
--- a/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java
+++ b/core/src/test/java/org/elasticsearch/update/UpdateByNativeScriptIT.java
@@ -57,7 +57,7 @@ public class UpdateByNativeScriptIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("foo", "SETVALUE");
client().prepareUpdate("test", "type", "1")
- .setScript(new Script("custom", ScriptType.INLINE, NativeScriptEngineService.NAME, params)).get();
+ .setScript(new Script(ScriptType.INLINE, NativeScriptEngineService.NAME, "custom", params)).get();
Map<String, Object> data = client().prepareGet("test", "type", "1").get().getSource();
assertThat(data, hasKey("foo"));
diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java
index b662f7034c..a3903023ed 100644
--- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java
+++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java
@@ -369,7 +369,7 @@ public class UpdateIT extends ESIntegTestCase {
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject())
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -381,7 +381,7 @@ public class UpdateIT extends ESIntegTestCase {
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject())
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.execute().actionGet();
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -410,7 +410,7 @@ public class UpdateIT extends ESIntegTestCase {
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("balance", openingBalance).endObject())
.setScriptedUpsert(true)
- .setScript(new Script("", ScriptType.INLINE, "scripted_upsert", params))
+ .setScript(new Script(ScriptType.INLINE, "scripted_upsert", "", params))
.execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -424,7 +424,7 @@ public class UpdateIT extends ESIntegTestCase {
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("balance", openingBalance).endObject())
.setScriptedUpsert(true)
- .setScript(new Script("", ScriptType.INLINE, "scripted_upsert", params))
+ .setScript(new Script(ScriptType.INLINE, "scripted_upsert", "", params))
.execute().actionGet();
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -468,7 +468,7 @@ public class UpdateIT extends ESIntegTestCase {
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("bar", "baz").endObject())
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("extra", "foo")))
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("extra", "foo")))
.setFetchSource(true)
.execute().actionGet();
@@ -480,7 +480,7 @@ public class UpdateIT extends ESIntegTestCase {
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("bar", "baz").endObject())
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("extra", "foo")))
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("extra", "foo")))
.setFields("_source")
.execute().actionGet();
@@ -498,24 +498,24 @@ public class UpdateIT extends ESIntegTestCase {
index("test", "type", "1", "text", "value"); // version is now 1
assertThrows(client().prepareUpdate(indexOrAlias(), "type", "1")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2"))).setVersion(2)
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("text", "v2"))).setVersion(2)
.execute(),
VersionConflictEngineException.class);
client().prepareUpdate(indexOrAlias(), "type", "1")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2"))).setVersion(1).get();
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("text", "v2"))).setVersion(1).get();
assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(2L));
// and again with a higher version..
client().prepareUpdate(indexOrAlias(), "type", "1")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v3"))).setVersion(2).get();
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("text", "v3"))).setVersion(2).get();
assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(3L));
// after delete
client().prepareDelete("test", "type", "1").get();
assertThrows(client().prepareUpdate("test", "type", "1")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2"))).setVersion(3)
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("text", "v2"))).setVersion(3)
.execute(),
DocumentMissingException.class);
@@ -523,7 +523,7 @@ public class UpdateIT extends ESIntegTestCase {
client().prepareIndex("test", "type", "2").setSource("text", "value").setVersion(10).setVersionType(VersionType.EXTERNAL).get();
assertThrows(client().prepareUpdate(indexOrAlias(), "type", "2")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2"))).setVersion(2)
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("text", "v2"))).setVersion(2)
.setVersionType(VersionType.EXTERNAL).execute(),
ActionRequestValidationException.class);
@@ -535,7 +535,7 @@ public class UpdateIT extends ESIntegTestCase {
// With internal versions, tt means "if object is there with version X, update it or explode. If it is not there, index.
client().prepareUpdate(indexOrAlias(), "type", "3")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2")))
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("text", "v2")))
.setVersion(10).setUpsert("{ \"text\": \"v0\" }").get();
get = get("test", "type", "3");
assertThat(get.getVersion(), equalTo(1L));
@@ -548,7 +548,7 @@ public class UpdateIT extends ESIntegTestCase {
public void testIndexAutoCreation() throws Exception {
UpdateResponse updateResponse = client().prepareUpdate("test", "type1", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("bar", "baz").endObject())
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("extra", "foo")))
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("extra", "foo")))
.setFetchSource(true)
.execute().actionGet();
@@ -565,7 +565,7 @@ public class UpdateIT extends ESIntegTestCase {
try {
client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null)).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap())).execute().actionGet();
fail();
} catch (DocumentMissingException e) {
// all is well
@@ -574,7 +574,7 @@ public class UpdateIT extends ESIntegTestCase {
client().prepareIndex("test", "type1", "1").setSource("field", 1).execute().actionGet();
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null)).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap())).execute().actionGet();
assertThat(updateResponse.getVersion(), equalTo(2L));
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -587,7 +587,7 @@ public class UpdateIT extends ESIntegTestCase {
Map<String, Object> params = new HashMap<>();
params.put("inc", 3);
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", params)).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", params)).execute().actionGet();
assertThat(updateResponse.getVersion(), equalTo(3L));
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -599,7 +599,7 @@ public class UpdateIT extends ESIntegTestCase {
// check noop
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("_ctx", Collections.singletonMap("op", "none")))).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("_ctx", Collections.singletonMap("op", "none")))).execute().actionGet();
assertThat(updateResponse.getVersion(), equalTo(3L));
assertEquals(DocWriteResponse.Result.NOOP, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -611,7 +611,7 @@ public class UpdateIT extends ESIntegTestCase {
// check delete
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("", ScriptType.INLINE, "put_values", Collections.singletonMap("_ctx", Collections.singletonMap("op", "delete")))).execute().actionGet();
+ .setScript(new Script(ScriptType.INLINE, "put_values", "", Collections.singletonMap("_ctx", Collections.singletonMap("op", "delete")))).execute().actionGet();
assertThat(updateResponse.getVersion(), equalTo(4L));
assertEquals(DocWriteResponse.Result.DELETED, updateResponse.getResult());
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -624,7 +624,7 @@ public class UpdateIT extends ESIntegTestCase {
// check fields parameter
client().prepareIndex("test", "type1", "1").setSource("field", 1).execute().actionGet();
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.setFields("field")
.setFetchSource(true)
.execute().actionGet();
@@ -637,7 +637,7 @@ public class UpdateIT extends ESIntegTestCase {
// check _source parameter
client().prepareIndex("test", "type1", "1").setSource("field1", 1, "field2", 2).execute().actionGet();
updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field1", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field1", Collections.emptyMap()))
.setFetchSource("field1", "field2")
.get();
assertThat(updateResponse.getIndex(), equalTo("test"));
@@ -700,7 +700,7 @@ public class UpdateIT extends ESIntegTestCase {
try {
client().prepareUpdate(indexOrAlias(), "type1", "1")
.setDoc(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject())
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.execute().actionGet();
fail("Should have thrown ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
@@ -715,7 +715,7 @@ public class UpdateIT extends ESIntegTestCase {
ensureGreen();
try {
client().prepareUpdate(indexOrAlias(), "type1", "1")
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.setDocAsUpsert(true)
.execute().actionGet();
fail("Should have thrown ActionRequestValidationException");
@@ -767,7 +767,7 @@ public class UpdateIT extends ESIntegTestCase {
// Update the first object and note context variables values
UpdateResponse updateResponse = client().prepareUpdate("test", "subtype1", "id1")
.setRouting("routing1")
- .setScript(new Script("", ScriptType.INLINE, "extract_ctx", null))
+ .setScript(new Script(ScriptType.INLINE, "extract_ctx", "", Collections.emptyMap()))
.execute().actionGet();
assertEquals(2, updateResponse.getVersion());
@@ -783,7 +783,7 @@ public class UpdateIT extends ESIntegTestCase {
// Idem with the second object
updateResponse = client().prepareUpdate("test", "type1", "parentId1")
- .setScript(new Script("", ScriptType.INLINE, "extract_ctx", null))
+ .setScript(new Script(ScriptType.INLINE, "extract_ctx", "", Collections.emptyMap()))
.execute().actionGet();
assertEquals(2, updateResponse.getVersion());
@@ -822,13 +822,13 @@ public class UpdateIT extends ESIntegTestCase {
}
if (useBulkApi) {
UpdateRequestBuilder updateRequestBuilder = client().prepareUpdate(indexOrAlias(), "type1", Integer.toString(i))
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.setRetryOnConflict(Integer.MAX_VALUE)
.setUpsert(jsonBuilder().startObject().field("field", 1).endObject());
client().prepareBulk().add(updateRequestBuilder).execute().actionGet();
} else {
client().prepareUpdate(indexOrAlias(), "type1", Integer.toString(i))
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.setRetryOnConflict(Integer.MAX_VALUE)
.setUpsert(jsonBuilder().startObject().field("field", 1).endObject())
.execute().actionGet();
@@ -948,7 +948,7 @@ public class UpdateIT extends ESIntegTestCase {
updateRequestsOutstanding.acquire();
try {
UpdateRequest ur = client().prepareUpdate("test", "type1", Integer.toString(j))
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.setRetryOnConflict(retryOnConflict)
.setUpsert(jsonBuilder().startObject().field("field", 1).endObject())
.request();
@@ -1048,7 +1048,7 @@ public class UpdateIT extends ESIntegTestCase {
//All the previous operations should be complete or failed at this point
for (int i = 0; i < numberOfIdsPerThread; ++i) {
UpdateResponse ur = client().prepareUpdate("test", "type1", Integer.toString(i))
- .setScript(new Script("field", ScriptType.INLINE, "field_inc", null))
+ .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
.setRetryOnConflict(Integer.MAX_VALUE)
.setUpsert(jsonBuilder().startObject().field("field", 1).endObject())
.execute().actionGet();