5.0.0-alpha5: Java API to execute search template queries

Prior to 5.0.0-alpha4 you could use the Java API to execute a search template like this:

        Template template = new Template("some-template-id", ScriptService.ScriptType.FILE, null, null, params);

        SearchRequestBuilder request = readClient.prepareSearch(index)
        SearchResponse response = request.execute().actionGet();

In 5.0.0-alpha4, the setTemplate() method on SearchRequestBuilder was removed, and, according to the commit, all of the search template related API was relocated.

I've tried looking in the unit tests to see if there are any examples of file based search templates getting executed, but I haven't had luck so far.

Does anyone know how to do the equivalent of the above using what's now available in 5.0.0-alpha5?

1 Like