|
facet.pivot自己的理解,就是按照多个维度进行分组查询,以下是自己的实战代码,按照newsType,property两个维度统计:
public List queryNewsType(
ReportQuery reportQuery) {
HttpSolrServer solrServer = SolrServer.getInstance().getServer();
SolrQuery sQuery = new SolrQuery();
List list = new ArrayList();
try {
String para = this.initReportQueryPara(reportQuery, 0);
sQuery.setFacet(true);
sQuery.add("facet.pivot", "newsType,property");//根据这两维度来分组查询
sQuery.setQuery(para);
QueryResponse response = solrServer.query(sQuery,SolrRequest.METHOD.POST);
NamedList namedList = response.getFacetPivot();
System.out.println(namedList);//底下为啥要这样判断,把这个值打印出来,你就明白了
if(namedList != null){
List pivotList = null;
for(int i=0;i |
|
|