diff --git a/src/main/java/org/elasticsearch/alerts/triggers/TriggerManager.java b/src/main/java/org/elasticsearch/alerts/triggers/TriggerManager.java index 328af7072ac..95fc3a0252a 100644 --- a/src/main/java/org/elasticsearch/alerts/triggers/TriggerManager.java +++ b/src/main/java/org/elasticsearch/alerts/triggers/TriggerManager.java @@ -45,8 +45,8 @@ public class TriggerManager extends AbstractComponent { triggersImplemented = ImmutableOpenMap.builder() .fPut("script", new ScriptedTriggerFactory(scriptService)) .build(); - this.fireTimePlaceHolder = settings.get("prefix", "<<>>"); - this.scheduledFireTimePlaceHolder = settings.get("postfix", "<<>>"); + this.fireTimePlaceHolder = settings.get("prefix", "{{FIRE_TIME}}"); + this.scheduledFireTimePlaceHolder = settings.get("postfix", "{{SCHEDULED_FIRE_TIME}}"); } /** diff --git a/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java b/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java index 1ecfcc082e1..c837d8ed819 100644 --- a/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java +++ b/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java @@ -122,21 +122,20 @@ public class BasicAlertingTest extends AbstractAlertingTests { @Test public void testTriggerSearch() throws Exception { assertAcked(prepareCreate("my-index").addMapping("my-type", "_timestamp", "enabled=true", "event_type", "type=string")); + + SearchSourceBuilder searchSource = searchSource().query( + filteredQuery(matchQuery("event_type", "a"), rangeFilter("_timestamp").from("{{SCHEDULED_FIRE_TIME}}||-30s").to("{{SCHEDULED_FIRE_TIME}}")) + ); client().preparePutIndexedScript() .setScriptLang("mustache") .setId("my-template") - .setSource(jsonBuilder().startObject().field("template").value(SearchSourceBuilder.searchSource().query( - filteredQuery(matchQuery("event_type", "a"), rangeFilter("_timestamp").from("{{SCHEDULED_FIRE_TIME}}||-30s").to("{{SCHEDULED_FIRE_TIME}}")) - )).endObject()) + .setSource(jsonBuilder().startObject().field("template").value(searchSource).endObject()) .get(); String alertName = "red-alert"; long scheduleTimeInMs = 5000; SearchRequest[] searchRequests = new SearchRequest[]{ - new SearchRequest("my-index").source(searchSource().query( - filteredQuery(matchQuery("event_type", "a"), rangeFilter("_timestamp").from("<<>>||-30s").to("<<>>")) - ) - ) + new SearchRequest("my-index").source(searchSource) // client().prepareSearch("my-index").setTemplateName("my-template").request() // TODO: add template source based search requests };