//前期设置好查询条件和参数
long numFound = 0;
SolrQuery query = new SolrQuery("*:*");
query.setQuery("text:keywords");
query.addFilterQuery("guid:"+"0102030102311111");
query.setStart(0);
query.setRows(0);
query.setParam("group", false);
SolrClient sserver = SolrUtils.getSelectServer();
//获取查询结果
1 QueryResponse results = sserver.query(query,METHOD.POST);
2 if ((query.getBool("group", false))) {
3 Object facets = results.getResponse().get("facets");
4 if(facets != null && facets instanceof SimpleOrderedMap){
5 Object distinctCount = ((SimpleOrderedMap)facets).get("distinctCount");
6 if(distinctCount != null ){
7 numFound = (Long)distinctCount;
8 }
9 }
10 } else {
11 numFound = results.getResults().getNumFound();
12 }