I am using Solr-5.0.0.
I am tying to query Solr using Java. I am using group by clause here.
Its my code
SolrQuery qry = new SolrQuery();
qry.setQuery("product_name:(laptops)");
qry.addFilterQuery("brand:dell OR brand: sony OR brand:samsung");
qry.setParam("group", true);
qry.setParam("group.field", "brand");
qry.setParam("stats", true);
qry.setParam("stats.field", "product_price");
qry.setFields("brand");
System.out.println(qry.toString());
QueryRequest qryReq = new QueryRequest(qry);
QueryResponse resp = qryReq.process(solr);
System.out.println(resp.getResponse().toString());
// Here I am getting required response;
SolrDocumentList docs = resp.getResults();
//Below code giving me exception null pointer
for(int i = 0; i < docs.size(); i++) {
System.out.println(docs.get(i));
}
But I am not able to parse the result of the query.I just need to get the brands and its corresponding count from the query in list or array