Example usage for org.apache.solr.response SolrQueryResponse getToLogAsString

List of usage examples for org.apache.solr.response SolrQueryResponse getToLogAsString

Introduction

In this page you can find the example usage for org.apache.solr.response SolrQueryResponse getToLogAsString.

Prototype

public String getToLogAsString(String logid) 

Source Link

Document

Returns a string of the form "logid name1=value1 name2=value2 ..."

Usage

From source file:de.qaware.chronix.solr.query.analysis.AnalysisHandler.java

License:Apache License

@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
    LOGGER.debug("Handling analysis request {}", req);
    //First check if the request should return documents => rows > 0
    SolrParams params = req.getParams();
    String rowsParam = params.get(CommonParams.ROWS, null);
    int rows = -1;
    if (rowsParam != null) {
        rows = Integer.parseInt(rowsParam);
    }/* w w w. j  a  va2s. co m*/

    SolrDocumentList results = new SolrDocumentList();
    String[] filterQueries = req.getParams().getParams(CommonParams.FQ);

    //Do a query and collect them on the join function
    Map<String, List<SolrDocument>> collectedDocs = findDocuments(req,
            JoinFunctionEvaluator.joinFunction(filterQueries));

    //If now rows should returned, we only return the num found
    if (rows == 0) {
        results.setNumFound(collectedDocs.keySet().size());
    } else {
        //Otherwise return the aggregated time series
        long queryStart = Long.parseLong(params.get(ChronixQueryParams.QUERY_START_LONG));
        long queryEnd = Long.parseLong(params.get(ChronixQueryParams.QUERY_END_LONG));

        //We have an analysis query
        List<SolrDocument> aggregatedDocs = analyze(collectedDocs,
                AnalysisQueryEvaluator.buildAnalysis(filterQueries), queryStart, queryEnd);

        results.addAll(aggregatedDocs);
        results.setNumFound(aggregatedDocs.size());
    }
    rsp.add("response", results);
    LOGGER.debug("Sending response {}",
            rsp.getToLogAsString(String.join("-", filterQueries == null ? "" : "")) + "/");

}

From source file:org.vootoo.server.RequestProcesser.java

License:Apache License

protected void handleAdminRequest(SolrRequestHandler handler, SolrQueryRequest solrReq) throws IOException {
    SolrQueryResponse solrResp = new SolrQueryResponse();
    SolrCore.preDecorateResponse(solrReq, solrResp);
    handler.handleRequest(solrReq, solrResp);
    SolrCore.postDecorateResponse(handler, solrReq, solrResp);
    if (logger.isInfoEnabled() && solrResp.getToLog().size() > 0) {
        logger.info(solrResp.getToLogAsString("[admin] "));
    }/*from  w  ww.  j a va 2s.c  o  m*/
    QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS
            .get(solrReq.getParams().get(CommonParams.WT));
    if (respWriter == null)
        respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get("standard");
    writeResponse(solrResp, respWriter, solrReq);
}