Example usage for org.apache.solr.client.solrj.impl BinaryResponseParser processResponse

List of usage examples for org.apache.solr.client.solrj.impl BinaryResponseParser processResponse

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.impl BinaryResponseParser processResponse.

Prototype

@Override
    public NamedList<Object> processResponse(InputStream body, String encoding) 

Source Link

Usage

From source file:com.doculibre.constellio.wicket.servlet.SolrServletEmulator.java

License:Open Source License

/**
 * Parse the solr response to named list (need to create solrj query
 * respond)./*  w  w w .  ja  v  a  2 s  .  c  o  m*/
 * 
 * @param req
 *            The request.
 * @param rsp
 *            The response.
 * @return The named list.
 */
public NamedList<Object> getParsedResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
    try {
        BinaryResponseWriter writer = new BinaryResponseWriter();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        writer.write(bos, req, rsp);
        BinaryResponseParser parser = new BinaryResponseParser();
        return parser.processResponse(new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}