Reputation: 39
i'm new in using SOLR as a searcher. I'm using the standard SolrServlet as a searcher, e.g.
final SolrCore core = SolrCore.getSolrCore();
SolrServletRequest solrReq = new SolrServletRequest(core, request);
SolrQueryResponse solrRsp = new SolrQueryResponse();
try {
SolrRequestHandler handler = core.getRequestHandler(solrReq.getQueryType());
if (handler==null) {
log.warning("Unknown Request Handler '" + solrReq.getQueryType() +"' :" + solrReq);
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Unknown Request Handler '" + solrReq.getQueryType() + "'", true);
}
core.execute(handler, solrReq, solrRsp );
if (solrRsp.getException() == null) {
QueryResponseWriter responseWriter = core.getQueryResponseWriter(solrReq);
response.setContentType(responseWriter.getContentType(solrReq, solrRsp));
PrintWriter out = response.getWriter();
Set<String> fields = new HashSet<String>();
fields.add("content");
solrRsp.setReturnFields(fields);
responseWriter.write(out, solrReq, solrRsp);
I'm getting the correct answers, but what I'm asking is how can I get the content of the response before it is written from the writer? I know that the return is doc, and I have a field "content" in the doc that I want to get, but before the response page is generated.
Thanks a lot
Upvotes: 0
Views: 1150
Reputation: 99720
The standard way of using Solr in Java is through SolrJ. SolrServletRequest, SolrRequestHandler, etc, are "internal" classes of Solr, not meant to be generally used by consumers.
You can also embed Solr in your application, although it's not generally recommended.
Upvotes: 2