use of com.yahoo.processing.rendering.Renderer in project vespa by vespa-engine.
the class SearchHandler method handleBody.
private HttpSearchResponse handleBody(HttpRequest request) {
// Find query profile
String queryProfileName = request.getProperty("queryProfile");
CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName);
boolean benchmarkOutput = VespaHeaders.benchmarkOutput(request);
// Create query
Query query = new Query(request, queryProfile);
boolean benchmarkCoverage = VespaHeaders.benchmarkCoverage(benchmarkOutput, request.getJDiscRequest().headers());
// Find and execute search chain if we have a valid query
String invalidReason = query.validate();
Chain<Searcher> searchChain = null;
String searchChainName = null;
if (invalidReason == null) {
Tuple2<String, Chain<Searcher>> nameAndChain = resolveChain(query.properties().getString(Query.SEARCH_CHAIN));
searchChainName = nameAndChain.first;
searchChain = nameAndChain.second;
}
// Create the result
Result result;
if (invalidReason != null) {
result = new Result(query, ErrorMessage.createIllegalQuery(invalidReason));
} else if (queryProfile == null && queryProfileName != null) {
result = new Result(query, ErrorMessage.createIllegalQuery("Could not resolve query profile '" + queryProfileName + "'"));
} else if (searchChain == null) {
result = new Result(query, ErrorMessage.createInvalidQueryParameter("No search chain named '" + searchChainName + "' was found"));
} else {
String pathAndQuery = UriTools.rawRequest(request.getUri());
result = search(pathAndQuery, query, searchChain, searchChainRegistry);
}
Renderer renderer;
if (result.getTemplating().usesDefaultTemplate()) {
renderer = toRendererCopy(query.getPresentation().getRenderer());
// pre-Vespa 6 Result.getEncoding() expects this to be set. TODO: Remove
result.getTemplating().setRenderer(renderer);
} else {
// somebody explicitly assigned a old style template
renderer = perRenderingCopy(result.getTemplating().getRenderer());
}
// Transform result to response
HttpSearchResponse response = new HttpSearchResponse(getHttpResponseStatus(request, result), result, query, renderer);
if (hostResponseHeaderKey.isPresent())
response.headers().add(hostResponseHeaderKey.get(), selfHostname);
if (benchmarkOutput)
VespaHeaders.benchmarkOutput(response.headers(), benchmarkCoverage, response.getTiming(), response.getHitCounts(), getErrors(result), response.getCoverage());
return response;
}
use of com.yahoo.processing.rendering.Renderer in project vespa by vespa-engine.
the class RendererRegistry method addTemplateSet.
@SuppressWarnings({ "deprecation", "unchecked" })
private ComponentId addTemplateSet(UserTemplate<?> templateSet) {
Renderer renderer = new SearchRendererAdaptor(templateSet);
ComponentId rendererId = new ComponentId(templateSet.getName());
renderer.initId(rendererId);
register(rendererId, renderer);
return rendererId;
}
Aggregations