What replaced SearchRequest.templateSource()?

I'm migrating a RestAction plugin from ES 2.0 to 5.5.
I'm stuck at this line for now:
searchRequest.templateSource()
Prior to this the original plugin goes through some acrobatics to modify the query, change the template to query etc.
The original can be found here: https://svn.apache.org/repos/asf/manifoldcf/integration/elasticsearch-2.0/trunk/src/main/java/org/apache/manifoldcf/elasticsearch/
and the offending file/line is MCFAuthorizerRestSearchAction.java line (arounbd) 114.
Any help would be much appreciated.
Also, if I should be using some other path to get to a better result, please suggest it.
Thank you.

'try {
requestJSON = objectMapper.readTree(RestActions.getRestContent(request).toBytes());
if (isTemplateRequest) {
modifiedJSON = (ObjectNode) requestJSON;
innerJSON = (ObjectNode)requestJSON.findValue("template");
filteredQueryBuilder = QueryBuilders.filteredQuery(QueryBuilders.wrapperQuery(innerJSON.findValue("query").toString()), authorizationFilter);
modifiedJSON.replace("template",innerJSON.set("query", objectMapper.readTree(filteredQueryBuilder.buildAsBytes().toBytes())));
searchRequest.templateSource(modifiedJSON.toString());
} else {
filteredQueryBuilder = QueryBuilders.filteredQuery(QueryBuilders.wrapperQuery(requestJSON.findValue("query").toString()), authorizationFilter);
modifiedJSON = (ObjectNode) requestJSON;
modifiedJSON.set("query", objectMapper.readTree(filteredQueryBuilder.buildAsBytes().toBytes()));
searchRequest.source(modifiedJSON.toString());
}
} catch (IOException e) {
throw new MCFAuthorizerException("JSON parser error: "+e.getMessage(), e);
}`

You might want to take a look at SearchTemplateRequest

Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.