现在开发的项目用到了Lucene,但是需要对搜索结果进行分组统计,于是就用了bobo-browse组件但是现在有个问题,bobo-browse对库里面所有的索引进行了分组统计,而不是对搜索结果进行统计例如:搜索“刘德华“,用"type"进行分组统计,搜索结果:包含“刘德华”的数据共 32 条分组统计结果: 电影:8921条,游戏:5679条,音频:2389条我想要的分组统计结果为:电影:14条,音频:18条  ,,只对搜索结果统计一下就可以了,不要索引库中所有的统计结果
代码如下:@Test
public void testabc() throws Exception {
// This is the directory that hosts the Lucene index

String splittype = "parentType";

File indexDir = new File("/home/qc/cms/resfile/index");
Directory idx = FSDirectory.open(indexDir);
IndexReader reader = IndexReader.open(idx);  
BoboIndexReader boboIndexReader = BoboIndexReader.getInstance(reader); 
BrowseRequest browseRequest = new BrowseRequest();  
browseRequest.setCount(10);  
browseRequest.setOffset(1);

String[] fields = {"name"};
String keywords = "刘德华";  
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
QueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, analyzer);  

Query query = queryParser.parse(keywords);  
browseRequest.setQuery(query);   FacetSpec facetSpec = new FacetSpec();
facetSpec.setMaxCount(100);// 搜索出来的标签数目
facetSpec.setOrderBy(FacetSortSpec.OrderHitsDesc); browseRequest.setFacetSpec(splittype, facetSpec); Browsable browser = new BoboBrowser(boboIndexReader);
BrowseResult browseResult = browser.browse(browseRequest); int totalHits = browseResult.getNumHits();
BrowseHit[] browseHit = browseResult.getHits(); System.out.println("命中数据共:" + totalHits);

Map<String, FacetAccessible> facetMap = browseResult.getFacetMap(); SimpleFacetHandler.SimpleFacetCountCollector colorFacets = (SimpleFacetHandler.SimpleFacetCountCollector) facetMap
.get(splittype);
colorFacets.collectAll();

List<BrowseFacet> facetVals = colorFacets.getFacets();
for (BrowseFacet f : facetVals) {
System.out.println(f.getValue() + "(" + f.getHitCount() + ")");


}