Example usage for org.apache.solr.client.solrj.impl NoOpResponseParser setWriterType

List of usage examples for org.apache.solr.client.solrj.impl NoOpResponseParser setWriterType

Introduction

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

Prototype

public void setWriterType(String writerType) 

Source Link

Usage

From source file:com.sitewhere.connectors.solr.search.SolrSearchProvider.java

License:Open Source License

@Override
public JsonNode executeQueryWithRawResponse(String queryString) throws SiteWhereException {
    try {/*from   ww  w.j a  va2 s. c o  m*/
        LOGGER.debug("About to execute Solr search with query string: " + queryString);

        NoOpResponseParser rawJsonResponseParser = new NoOpResponseParser();
        rawJsonResponseParser.setWriterType("json");

        SolrQuery query = new SolrQuery();
        query.add(createParamsFromQueryString(queryString));
        QueryRequest request = new QueryRequest(query);
        request.setResponseParser(rawJsonResponseParser);
        NamedList<?> results = getSolr().getSolrClient().request(request);
        return MAPPER.readTree((String) results.get("response"));
    } catch (SolrServerException e) {
        throw new SiteWhereException("Unable to execute query.", e);
    } catch (IOException e) {
        throw new SiteWhereException("Unable to execute query.", e);
    }
}