Core: Change <<< placeholder to {{

Original commit: elastic/x-pack-elasticsearch@39d2de2dd8
This commit is contained in:
Martijn van Groningen 2014-11-13 18:39:23 +01:00
parent f58b36b70a
commit 6a5a1710d0
2 changed files with 8 additions and 9 deletions

View File

@ -45,8 +45,8 @@ public class TriggerManager extends AbstractComponent {
triggersImplemented = ImmutableOpenMap.<String, TriggerFactory>builder() triggersImplemented = ImmutableOpenMap.<String, TriggerFactory>builder()
.fPut("script", new ScriptedTriggerFactory(scriptService)) .fPut("script", new ScriptedTriggerFactory(scriptService))
.build(); .build();
this.fireTimePlaceHolder = settings.get("prefix", "<<<FIRE_TIME>>>"); this.fireTimePlaceHolder = settings.get("prefix", "{{FIRE_TIME}}");
this.scheduledFireTimePlaceHolder = settings.get("postfix", "<<<SCHEDULED_FIRE_TIME>>>"); this.scheduledFireTimePlaceHolder = settings.get("postfix", "{{SCHEDULED_FIRE_TIME}}");
} }
/** /**

View File

@ -122,21 +122,20 @@ public class BasicAlertingTest extends AbstractAlertingTests {
@Test @Test
public void testTriggerSearch() throws Exception { public void testTriggerSearch() throws Exception {
assertAcked(prepareCreate("my-index").addMapping("my-type", "_timestamp", "enabled=true", "event_type", "type=string")); 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() client().preparePutIndexedScript()
.setScriptLang("mustache") .setScriptLang("mustache")
.setId("my-template") .setId("my-template")
.setSource(jsonBuilder().startObject().field("template").value(SearchSourceBuilder.searchSource().query( .setSource(jsonBuilder().startObject().field("template").value(searchSource).endObject())
filteredQuery(matchQuery("event_type", "a"), rangeFilter("_timestamp").from("{{SCHEDULED_FIRE_TIME}}||-30s").to("{{SCHEDULED_FIRE_TIME}}"))
)).endObject())
.get(); .get();
String alertName = "red-alert"; String alertName = "red-alert";
long scheduleTimeInMs = 5000; long scheduleTimeInMs = 5000;
SearchRequest[] searchRequests = new SearchRequest[]{ SearchRequest[] searchRequests = new SearchRequest[]{
new SearchRequest("my-index").source(searchSource().query( new SearchRequest("my-index").source(searchSource)
filteredQuery(matchQuery("event_type", "a"), rangeFilter("_timestamp").from("<<<SCHEDULED_FIRE_TIME>>>||-30s").to("<<<SCHEDULED_FIRE_TIME>>>"))
)
)
// client().prepareSearch("my-index").setTemplateName("my-template").request() // client().prepareSearch("my-index").setTemplateName("my-template").request()
// TODO: add template source based search requests // TODO: add template source based search requests
}; };