Convert script uses to use source/id keys (elastic/x-pack-elasticsearch#1670)

This is the xpack side of
https://github.com/elastic/elasticsearch/pull/25127

Original commit: elastic/x-pack-elasticsearch@e25bd90825
This commit is contained in:
Ryan Ernst 2017-06-09 08:29:36 -07:00 committed by GitHub
parent 15e4958d4e
commit c1a3f50e19
36 changed files with 72 additions and 72 deletions

View File

@ -66,7 +66,7 @@ format. For example, the following Painless script transforms
"script_fields": {
"lat-lon": {
"script": {
"inline": "doc['coords'].lat + ',' + doc['coords'].lon",
"source": "doc['coords'].lat + ',' + doc['coords'].lon",
"lang": "painless"
}
}

View File

@ -58,7 +58,7 @@ A {dfeed} resource has the following properties:
"total_error_count": {
"script": {
"lang": "painless",
"inline": "doc['error_count'].value + doc['aborted_count'].value"
"source": "doc['error_count'].value + doc['aborted_count'].value"
}
}
}

View File

@ -320,7 +320,7 @@ of the current authenticated user:
"privileges" : [ "read" ],
"query" : {
"template" : {
"inline" : {
"source" : {
"term" : { "acl.username" : "{{_user.username}}" }
}
}
@ -355,7 +355,7 @@ based on the `group.id` field in your documents:
"privileges" : [ "read" ],
"query" : {
"template" : {
"inline" : {
"source" : {
"term" : { "group.id" : "{{_user.metadata.group_id}}" }
}
}

View File

@ -108,7 +108,7 @@ aggregation and the Slack action:
"throttle_period" : "5m",
"transform" : {
"script" : {
"inline" : "['items': ctx.payload.aggregations.users_per_month.buckets.collect(bucket -> ['count': bucket.doc_count, 'name': bucket.key_as_string, 'color': bucket.doc_count < 100 ? 'danger' : 'good'])]",
"source" : "['items': ctx.payload.aggregations.users_per_month.buckets.collect(bucket -> ['count': bucket.doc_count, 'name': bucket.key_as_string, 'color': bucket.doc_count < 100 ? 'danger' : 'good'])]",
"lang" : "painless"
}
},

View File

@ -35,7 +35,7 @@ parameter, `result`:
--------------------------------------------------
"condition" : {
"script" : {
"inline" : "return result",
"source" : "return result",
"lang" : "painless",
"params" : {
"result" : true
@ -55,7 +55,7 @@ always returns `true`.
--------------------------------------------------
"condition" : {
"script" : {
"inline" : "return true"
"source" : "return true"
}
}
--------------------------------------------------
@ -113,7 +113,7 @@ threshold:
},
"condition" : {
"script" : {
"inline" : "return ctx.payload.hits.total > threshold",
"source" : "return ctx.payload.hits.total > threshold",
"params" : {
"threshold" : 5
}

View File

@ -171,7 +171,7 @@ VIX quote loaded by the `http` input is either greater than 5% or lower than -5%
--------------------------------------------------
"condition" : {
"script" : {
"inline" : "Math.abs(ctx.payload.hits.hits[0]._source.ChangePercent) > 5",
"source" : "Math.abs(ctx.payload.hits.hits[0]._source.ChangePercent) > 5",
"lang" : "painless"
}
}

View File

@ -204,7 +204,7 @@ PUT _xpack/watcher/watch/rss_watch
}
--------------------------------------------------
// CONSOLE
// TEST[s/"id" : "threshold_hits"/"inline": "return ctx.payload.hits.total > params.threshold"/]
// TEST[s/"id" : "threshold_hits"/"source": "return ctx.payload.hits.total > params.threshold"/]
<1> Replace `<username>@<domainname>` with your email address to receive
notifications.

View File

@ -387,7 +387,7 @@ definition as the field value. For example:
"email_notification" : {
"email" : {
"subject" : {
"inline" : "{{ctx.metadata.color}} alert"
"source" : "{{ctx.metadata.color}} alert"
}
}
}
@ -400,7 +400,7 @@ The formal object definition for a script would be:
----------------------------------------------------------------------
"condition" : {
"script" : {
"inline": "return true"
"source": "return true"
}
}
----------------------------------------------------------------------

View File

@ -144,7 +144,7 @@ The following is an example of using templates that refer to provided parameters
"indices" : [ "logstash-*" ],
"types" : [ "event" ],
"template" : {
"inline" : {
"source" : {
"size" : 0,
"query" : {
"bool" : {

View File

@ -162,7 +162,7 @@ public final class MonitoringTemplateUtils {
.startObject()
// Drop the .monitoring-data-2 index and effectively drop unnecessary data (duplicate or simply unused)
.startObject("script")
.field("inline",
.field("source",
"boolean legacyIndex = ctx._index == '.monitoring-data-2';" +
"if (legacyIndex || ctx._index.startsWith('.monitoring-es-2')) {" +
"if (ctx._type == 'cluster_info') {" +

View File

@ -103,13 +103,13 @@
},
"condition": {
"script": {
"inline":
"source":
"ctx.vars.fails_check = ctx.payload.check.hits.total != 0 && ctx.payload.check.hits.hits[0]._source.cluster_state.status != 'green';ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved"
}
},
"transform": {
"script": {
"inline":
"source":
"def state = 'red';if (ctx.vars.fails_check){state = ctx.payload.check.hits.hits[0]._source.cluster_state.status;}if (ctx.vars.not_resolved){ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check == false) {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = ['timestamp': ctx.execution_time, 'metadata': ctx.metadata.xpack];}if (ctx.vars.fails_check) {ctx.payload.prefix = 'Elasticsearch cluster status is ' + state + '.';if (state == 'red') {ctx.payload.message = 'Allocate missing primary shards and replica shards.';ctx.payload.metadata.severity = 2100;} else {ctx.payload.message = 'Allocate missing replica shards.';ctx.payload.metadata.severity = 1100;}}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
}
},

View File

@ -99,12 +99,12 @@
},
"condition": {
"script": {
"inline": "ctx.vars.fails_check = ctx.payload.check.hits.total != 0 && ctx.payload.check.hits.hits[0]._source.cluster_stats.nodes.versions.size() != 1;ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved;"
"source": "ctx.vars.fails_check = ctx.payload.check.hits.total != 0 && ctx.payload.check.hits.hits[0]._source.cluster_stats.nodes.versions.size() != 1;ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved;"
}
},
"transform": {
"script": {
"inline": "def versionMessage = null;if (ctx.vars.fails_check) {def versions = new ArrayList(ctx.payload.check.hits.hits[0]._source.cluster_stats.nodes.versions);Collections.sort(versions);versionMessage = 'Versions: [' + String.join(', ', versions) + '].';}if (ctx.vars.not_resolved) {ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check) {ctx.payload.message = versionMessage;} else {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = [ 'timestamp': ctx.execution_time, 'prefix': 'This cluster is running with multiple versions of Elasticsearch.', 'message': versionMessage, 'metadata': ctx.metadata.xpack ];}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
"source": "def versionMessage = null;if (ctx.vars.fails_check) {def versions = new ArrayList(ctx.payload.check.hits.hits[0]._source.cluster_stats.nodes.versions);Collections.sort(versions);versionMessage = 'Versions: [' + String.join(', ', versions) + '].';}if (ctx.vars.not_resolved) {ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check) {ctx.payload.message = versionMessage;} else {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = [ 'timestamp': ctx.execution_time, 'prefix': 'This cluster is running with multiple versions of Elasticsearch.', 'message': versionMessage, 'metadata': ctx.metadata.xpack ];}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
}
},
"actions": {

View File

@ -126,12 +126,12 @@
},
"condition": {
"script": {
"inline": "ctx.vars.fails_check = false;if (ctx.payload.check.hits.total != 0 && ctx.payload.check.aggregations.group_by_kibana.buckets.size() > 1) {def versions = new HashSet();for (def kibana : ctx.payload.check.aggregations.group_by_kibana.buckets) {if (kibana.group_by_version.buckets.size() != 0) {versions.add(kibana.group_by_version.buckets[0].key);}}if (versions.size() > 1) {ctx.vars.fails_check = true;ctx.vars.versions = new ArrayList(versions);Collections.sort(ctx.vars.versions);}}ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved;"
"source": "ctx.vars.fails_check = false;if (ctx.payload.check.hits.total != 0 && ctx.payload.check.aggregations.group_by_kibana.buckets.size() > 1) {def versions = new HashSet();for (def kibana : ctx.payload.check.aggregations.group_by_kibana.buckets) {if (kibana.group_by_version.buckets.size() != 0) {versions.add(kibana.group_by_version.buckets[0].key);}}if (versions.size() > 1) {ctx.vars.fails_check = true;ctx.vars.versions = new ArrayList(versions);Collections.sort(ctx.vars.versions);}}ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved;"
}
},
"transform": {
"script": {
"inline": "def versionMessage = null;if (ctx.vars.fails_check) {versionMessage = 'Versions: [' + String.join(', ', ctx.vars.versions) + '].';}if (ctx.vars.not_resolved) {ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check) {ctx.payload.message = versionMessage;} else {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = [ 'timestamp': ctx.execution_time, 'prefix': 'This cluster is running with multiple versions of Kibana.', 'message': versionMessage, 'metadata': ctx.metadata.xpack ];}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
"source": "def versionMessage = null;if (ctx.vars.fails_check) {versionMessage = 'Versions: [' + String.join(', ', ctx.vars.versions) + '].';}if (ctx.vars.not_resolved) {ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check) {ctx.payload.message = versionMessage;} else {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = [ 'timestamp': ctx.execution_time, 'prefix': 'This cluster is running with multiple versions of Kibana.', 'message': versionMessage, 'metadata': ctx.metadata.xpack ];}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
}
},
"actions": {

View File

@ -126,12 +126,12 @@
},
"condition": {
"script": {
"inline": "ctx.vars.fails_check = false;if (ctx.payload.check.hits.total != 0 && ctx.payload.check.aggregations.group_by_logstash.buckets.size() > 1) {def versions = new HashSet();for (def logstash : ctx.payload.check.aggregations.group_by_logstash.buckets) {if (logstash.group_by_version.buckets.size() != 0) {versions.add(logstash.group_by_version.buckets[0].key);}}if (versions.size() > 1) {ctx.vars.fails_check = true;ctx.vars.versions = new ArrayList(versions);Collections.sort(ctx.vars.versions);}}ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved;"
"source": "ctx.vars.fails_check = false;if (ctx.payload.check.hits.total != 0 && ctx.payload.check.aggregations.group_by_logstash.buckets.size() > 1) {def versions = new HashSet();for (def logstash : ctx.payload.check.aggregations.group_by_logstash.buckets) {if (logstash.group_by_version.buckets.size() != 0) {versions.add(logstash.group_by_version.buckets[0].key);}}if (versions.size() > 1) {ctx.vars.fails_check = true;ctx.vars.versions = new ArrayList(versions);Collections.sort(ctx.vars.versions);}}ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved;"
}
},
"transform": {
"script": {
"inline": "def versionMessage = null;if (ctx.vars.fails_check) {versionMessage = 'Versions: [' + String.join(', ', ctx.vars.versions) + '].';}if (ctx.vars.not_resolved) {ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check) {ctx.payload.message = versionMessage;} else {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = [ 'timestamp': ctx.execution_time, 'prefix': 'This cluster is running with multiple versions of Logstash.', 'message': versionMessage, 'metadata': ctx.metadata.xpack ];}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
"source": "def versionMessage = null;if (ctx.vars.fails_check) {versionMessage = 'Versions: [' + String.join(', ', ctx.vars.versions) + '].';}if (ctx.vars.not_resolved) {ctx.payload = ctx.payload.alert.hits.hits[0]._source;if (ctx.vars.fails_check) {ctx.payload.message = versionMessage;} else {ctx.payload.resolved_timestamp = ctx.execution_time;}} else {ctx.payload = [ 'timestamp': ctx.execution_time, 'prefix': 'This cluster is running with multiple versions of Logstash.', 'message': versionMessage, 'metadata': ctx.metadata.xpack ];}ctx.payload.update_timestamp = ctx.execution_time;return ctx.payload;"
}
},
"actions": {

View File

@ -118,10 +118,10 @@ public class TextTemplateTests extends ESTestCase {
XContentBuilder builder = jsonBuilder().startObject();
switch (type) {
case INLINE:
builder.field("inline", template.getTemplate());
builder.field("source", template.getTemplate());
break;
case STORED:
builder.field("stored", template.getTemplate());
builder.field("id", template.getTemplate());
}
builder.field("params", template.getParams());
builder.endObject();

View File

@ -319,7 +319,7 @@ public class ScrollDataExtractorTests extends ESTestCase {
assertThat(searchRequest, containsString("\"stored_fields\":\"_none_\""));
// Check for the scripts
assertThat(searchRequest, containsString("{\"script\":{\"inline\":\"return 1 + 1;\",\"lang\":\"mockscript\"}"
assertThat(searchRequest, containsString("{\"script\":{\"source\":\"return 1 + 1;\",\"lang\":\"mockscript\"}"
.replaceAll("\\s", "")));
assertThat(searchRequest, containsString("List domainSplit(String host, Map params)".replaceAll("\\s", "")));
assertThat(searchRequest, containsString("String replaceDots(String input) {".replaceAll("\\s", "")));

View File

@ -26,7 +26,7 @@ public class MockIngestPlugin extends Plugin implements IngestPlugin {
.put("gsub", new String[] { "field", "pattern", "replacement" })
.put("rename", new String[] { "field", "target_field" })
.put("set", new String[] { "field", "value" })
.put("script", new String[] { "inline" })
.put("script", new String[] { "source" })
.map();
return processorFields.entrySet()

View File

@ -141,7 +141,7 @@ public class ScriptConditionTests extends ESTestCase {
fail("expected a condition exception trying to parse an invalid condition XContent");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(),
containsString("must specify either code for an [inline] script or an id for a [stored] script"));
containsString("must specify either [source] for an inline script or [id] for a stored script"));
}
}
@ -211,10 +211,10 @@ public class ScriptConditionTests extends ESTestCase {
builder.startObject();
switch (scriptType) {
case INLINE:
builder.field("inline", script);
builder.field("source", script);
break;
case STORED:
builder.field("stored", script);
builder.field("id", script);
break;
default:
throw illegalArgument("unsupported script type [{}]", scriptType);

View File

@ -19,12 +19,12 @@ import static org.hamcrest.Matchers.equalTo;
public class WatcherSearchTemplateRequestTests extends ESTestCase {
public void testFromXContentWithTemplateDefaultLang() throws IOException {
String source = "{\"template\":{\"stored\":\"default-script\", \"params\":{\"foo\":\"bar\"}}}";
String source = "{\"template\":{\"id\":\"default-script\", \"params\":{\"foo\":\"bar\"}}}";
assertTemplate(source, "default-script", "mustache", singletonMap("foo", "bar"));
}
public void testFromXContentWithTemplateCustomLang() throws IOException {
String source = "{\"template\":{\"inline\":\"custom-script\", \"lang\":\"painful\",\"params\":{\"bar\":\"baz\"}}}";
String source = "{\"template\":{\"source\":\"custom-script\", \"lang\":\"painful\",\"params\":{\"bar\":\"baz\"}}}";
assertTemplate(source, "custom-script", "painful", singletonMap("bar", "baz"));
}

View File

@ -203,7 +203,7 @@ public class ScriptTransformTests extends ESTestCase {
if (scriptType == ScriptType.STORED) {
assertThat(e.getMessage(), containsString("unable to get stored script with unsupported lang [not_a_valid_lang]"));
assertWarnings("specifying the field [lang] for executing stored scripts is deprecated;" +
" use only the field [stored] to specify an <id>");
" use only the field [id] to specify an <id>");
} else {
assertThat(e.getMessage(), containsString("script_lang not supported [not_a_valid_lang]"));
}
@ -211,8 +211,8 @@ public class ScriptTransformTests extends ESTestCase {
static String scriptTypeField(ScriptType type) {
switch (type) {
case INLINE: return "inline";
case STORED: return "stored";
case INLINE: return "source";
case STORED: return "id";
default:
throw illegalArgument("unsupported script type [{}]", type);
}

View File

@ -354,7 +354,7 @@ public class WatchTests extends ESTestCase {
builder.field("script", "return true");
} else {
builder.startObject("script");
builder.field("inline", "return true");
builder.field("source", "return true");
builder.endObject();
}
builder.endObject();
@ -369,7 +369,7 @@ public class WatchTests extends ESTestCase {
builder.field("script", "return true");
} else {
builder.startObject("script");
builder.field("inline", "return true");
builder.field("source", "return true");
builder.endObject();
}
builder.endObject();

View File

@ -156,7 +156,7 @@
dest:
index: dest
script:
inline: if (ctx._source.user == "kimchy") {ctx._index = 'other_dest'}
source: if (ctx._source.user == "kimchy") {ctx._index = 'other_dest'}
- do:
indices.refresh: {}

View File

@ -201,7 +201,7 @@
dest:
index: dest
script:
inline: if (ctx._source.user == "kimchy") {ctx._index = 'other_dest'}
source: if (ctx._source.user == "kimchy") {ctx._index = 'other_dest'}
- do:
indices.refresh: {}

View File

@ -16,7 +16,7 @@
index: source
body:
script:
inline: ctx._source['hi'] = 'there'
source: ctx._source['hi'] = 'there'
- match: {updated: 1}
- do:
@ -47,7 +47,7 @@
index: source
body:
script:
inline: ctx._source['hi'] = 'there'
source: ctx._source['hi'] = 'there'
- match: {updated: 1}
- do:
@ -78,7 +78,7 @@
index: source
body:
script:
inline: ctx._source['hi'] = 'there'
source: ctx._source['hi'] = 'there'
- match: {updated: 1}
- do:
@ -151,7 +151,7 @@
index: source
body:
script:
inline: ctx._source['hi'] = 'there'
source: ctx._source['hi'] = 'there'
- match: {updated: 1}
# We only updated one doc, presumably the one without the hidden field
@ -196,7 +196,7 @@
index: source
body:
script:
inline: ctx._source['hi'] = ctx._source['text'] + ';' + ctx._source['foo']
source: ctx._source['hi'] = ctx._source['text'] + ';' + ctx._source['foo']
- match: {updated: 1}
- do:

View File

@ -47,7 +47,7 @@ setup:
"privileges": ["all"],
"query" : {
"template" : {
"inline" : {
"source" : {
"term" : { "username" : "{{_user.username}}" }
}
}
@ -67,7 +67,7 @@ setup:
"privileges": ["all"],
"query" : {
"template" : {
"inline" : "{\"terms\" : { \"username\" : {{#toJson}}_user.metadata.groups{{/toJson}} } }"
"source" : "{\"terms\" : { \"username\" : {{#toJson}}_user.metadata.groups{{/toJson}} } }"
}
}
}
@ -85,7 +85,7 @@ setup:
"privileges": ["all"],
"query" : {
"template" : {
"stored" : "1"
"id" : "1"
}
}
}

View File

@ -47,7 +47,7 @@ setup:
"privileges": ["all"],
"query" : {
"template" : {
"inline" : {
"source" : {
"term" : { "username" : "{{_user.username}}" }
}
}
@ -67,7 +67,7 @@ setup:
"privileges": ["all"],
"query" : {
"template" : {
"inline" : "{\"terms\" : { \"username\" : {{#toJson}}_user.metadata.groups{{/toJson}} } }"
"source" : "{\"terms\" : { \"username\" : {{#toJson}}_user.metadata.groups{{/toJson}} } }"
}
}
}
@ -85,7 +85,7 @@ setup:
"privileges": ["all"],
"query" : {
"template" : {
"stored" : "1"
"id" : "1"
}
}
}

View File

@ -74,7 +74,7 @@ teardown:
"privileges": ["read", "create"],
"query" : {
"template" : {
"inline" : {
"source" : {
"term" : { "user.username" : "{{_user.username}}" }
}
}
@ -142,7 +142,7 @@ teardown:
"privileges": ["read", "create"],
"query" : {
"template" : {
"inline" : {
"source" : {
"term" : { "user.metadata.customer_id" : "{{_user.metadata.customer_id}}" }
}
}

View File

@ -63,7 +63,7 @@ teardown:
search_template:
index: foobar
body:
inline:
source:
query:
match:
title: "{{query_string}}"
@ -80,7 +80,7 @@ teardown:
Authorization: "Basic aW5saW5lX3RlbXBsYXRlX3VzZXI6Y2hhbmdlbWU="
search_template:
body:
inline:
source:
query:
match:
title: "{{query_string}}"
@ -98,7 +98,7 @@ teardown:
search_template:
index: foo*
body:
inline:
source:
query:
match:
title: "{{query_string}}"
@ -116,7 +116,7 @@ teardown:
search_template:
index: unauthorized*
body:
inline:
source:
query:
match:
title: "{{query_string}}"
@ -134,14 +134,14 @@ teardown:
msearch_template:
body:
- index: foobar
- inline:
- source:
query:
match:
title: "{{query_string}}"
params:
query_string: "search for these words"
- index: unauthorized*
- inline:
- source:
query:
match:
title: "{{query_string}}"
@ -158,7 +158,7 @@ teardown:
Authorization: "Basic aW5saW5lX3RlbXBsYXRlX3VzZXI6Y2hhbmdlbWU="
render_search_template:
body:
inline:
source:
query:
match:
title: "{{query_string}}"

View File

@ -45,7 +45,7 @@
port: $port
path: "/my_index/my_type/{{ctx.watch_id}}"
body:
inline:
source:
watch_id: "{{ctx.watch_id}}"
params: {}

View File

@ -140,7 +140,7 @@ setup:
"request" : {
"indices" : "idx",
"template" : {
"stored": "search-template",
"id": "search-template",
"params": {
"num": 2
}
@ -156,6 +156,6 @@ setup:
- match: { "watch_record.result.input.payload.hits.hits.0._id": "2" }
# makes sure that the mustache template snippets have been resolved correctly:
- match: { "watch_record.result.input.search.request.body.query.bool.must.0.term.value": "val_2" }
- match: { "watch_record.result.input.search.request.template.stored": "search-template" }
- match: { "watch_record.result.input.search.request.template.id": "search-template" }
- match: { "watch_record.result.input.search.request.template.lang": "mustache" }
- match: { "watch_record.result.input.search.request.template.params.num": 2 }

View File

@ -130,7 +130,7 @@ setup:
"request" : {
"indices" : "idx",
"template" : {
"inline" : "{\"query\": {\"bool\" : { \"must\": [{\"term\": {\"value\": \"val_{{ctx.payload.number}}\"}}]}}}"
"source" : "{\"query\": {\"bool\" : { \"must\": [{\"term\": {\"value\": \"val_{{ctx.payload.number}}\"}}]}}}"
}
}
}

View File

@ -40,7 +40,7 @@
},
"condition" : {
"script" : {
"inline" : "ctx.payload.hits.total > 1",
"source" : "ctx.payload.hits.total > 1",
"lang" : "painless"
}
},

View File

@ -19,7 +19,7 @@
},
"condition" : {
"script" : {
"inline" : "ctx.payload.count == 1",
"source" : "ctx.payload.count == 1",
"lang" : "painless"
}
},

View File

@ -51,7 +51,7 @@
},
"condition" : {
"script" : {
"inline" : "ctx.payload.hits.total > 1",
"source" : "ctx.payload.hits.total > 1",
"lang" : "painless"
}
},

View File

@ -18,7 +18,7 @@
},
"condition" : {
"script" : {
"inline" : "FOO == 1",
"source" : "FOO == 1",
"lang" : "painless"
}
},

View File

@ -14,7 +14,7 @@
{
"script":{
"lang": "painless",
"code":"return [ 'email': 'foo@bar.org' ]"
"source":"return [ 'email': 'foo@bar.org' ]"
}
}
@ -33,7 +33,7 @@
},
"transform": {
"script": {
"stored": "transform-script"
"id": "transform-script"
}
},
"actions": {
@ -62,7 +62,7 @@
"script":
{
"lang": "painless",
"code":"return [ 'email': 'foo@example.org' ]"
"source":"return [ 'email': 'foo@example.org' ]"
}
}
@ -90,7 +90,7 @@
"script":
{
"lang": "painless",
"code": "return false"
"source": "return false"
}
}
@ -109,7 +109,7 @@
},
"condition": {
"script": {
"stored": "condition-script"
"id": "condition-script"
}
},
"actions": {
@ -137,7 +137,7 @@
{
"script": {
"lang": "painless",
"code": "return true"
"source": "return true"
}
}