Watcher 5-rc1 Java API. Where's searchRequest("idx") method?

Hi Elastic Watchers,

Following https://www.elastic.co/guide/en/x-pack/current/api-java.html, the guide says:

.input(searchInput(searchRequest("idx").source(...

But I can't find a searchRequest method anywhere.

Any ideas where it lives, or has it been replaced by something?

Best, Dan.

PS. Also, in the non-builder example, the WatcherSearchTemplateRequest constructor with a String as the final argument doesn't seem to exist.

I ended up with this (not good, just getting it to build for 5.0):

			BoolQueryBuilder query = QueryBuilders.boolQuery();
		SearchRequest source = Requests.searchRequest("idx") 
				.source(SearchSourceBuilder.searchSource()
						.query(query));

		//TODO build query

		
		Condition.Builder<?> condition = ConditionBuilders.alwaysCondition();
				
		WatchSourceBuilder watchBuilder = WatchSourceBuilders.watchBuilder()
				.trigger(TriggerBuilders.schedule(null)) //TODO Schedules.cron
				.input(InputBuilders.searchInput(new WatcherSearchTemplateRequest(new String[]{"idx"}, null, 
						SearchType.DEFAULT, WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS, 
						source.source().buildAsBytes())))
				.condition(condition)
				.addAction("build_epcis_document", ActionBuilders.webhookAction(
						HttpRequestTemplate.builder("localhost", 8181)
						.path("/internal/{{ctx.watch_id}}") 
						.body("{{ctx.payload}}")));

		watcherClient.preparePutWatch("id")
		.setSource(watchBuilder).get();

Hey,

searchRequest("idx") is just a static import of Requests.searchRequest, which you already used. They way I would write this query would be

WatchSourceBuilder watchBuilder = WatchSourceBuilders.watchBuilder()
        .trigger(TriggerBuilders.schedule(null)) //TODO Schedules.cron
        .input(searchInput(templateRequest(searchSource().query(QueryBuilders.matchAllQuery()), "idx")))
        .condition(alwaysCondition())
        .addAction("build_epcis_document", ActionBuilders.webhookAction(
                HttpRequestTemplate.builder("localhost", 8181)
                        .path("/internal/{{ctx.watch_id}}")
                        .body("{{ctx.payload}}")));

watcherClient.preparePutWatch("id").setSource(watchBuilder).get();

public static WatcherSearchTemplateRequest templateRequest(SearchSourceBuilder sourceBuilder, String... indices) {
    try {
        XContentBuilder xContentBuilder = jsonBuilder();
        xContentBuilder.value(sourceBuilder);
        return new WatcherSearchTemplateRequest(indices, new String[0], SearchType.DEFAULT,
                WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS, xContentBuilder.bytes());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

searchSource() is a static import from the SearchSourceBuilder class.

That said, I am going to check the java API docs now and fix them where needed.

Thanks a lot for your feedback!

--Alex