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()
.fPut("script", new ScriptedTriggerFactory(scriptService))
.build();
this.fireTimePlaceHolder = settings.get("prefix", "<<<FIRE_TIME>>>");
this.scheduledFireTimePlaceHolder = settings.get("postfix", "<<<SCHEDULED_FIRE_TIME>>>");
this.fireTimePlaceHolder = settings.get("prefix", "{{FIRE_TIME}}");
this.scheduledFireTimePlaceHolder = settings.get("postfix", "{{SCHEDULED_FIRE_TIME}}");
}
/**

View File

@ -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("<<<SCHEDULED_FIRE_TIME>>>||-30s").to("<<<SCHEDULED_FIRE_TIME>>>"))
)
)
new SearchRequest("my-index").source(searchSource)
// client().prepareSearch("my-index").setTemplateName("my-template").request()
// TODO: add template source based search requests
};