//统计数据 根据查询条件
public String getStats(String ipName) {
JSONObject obj;
JSONArray pageArray = new JSONArray();
SolrQuery query = factory.getQuery();
SolrServer sserver = SolrUtils.getSelectServer();
query.addFilterQuery("ipName:*" + ipName + "*");
query.set("stats", "true");
query.set("stats.field", "pageType");
query.set("stats.facet", "pageType");
query.setRows(0);
QueryResponse rsp = null;
try {
rsp = sserver.query(query);
} catch (SolrServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (rsp != null && rsp.getResults().getNumFound() != 0) {
for (FieldStatsInfo tmp : rsp.getFieldStatsInfo().get("pageType").getFacets().get("pageType")) {
obj = new JSONObject();
obj.put("name", tmp.getName());
obj.put("value", tmp.getCount());
pageArray.add(obj);
}
}
return pageArray.toString();
}