我正在尝试使用Lucene 4.6.1实现钻取边界搜索。 以下代码工作正常:
DrillSideways ds = new DrillSideways(searcher, taxoReader);
FacetSearchParams fsp = new FacetSearchParams(getAllFacetCounts());
DrillDownQuery ddq = new DrillDownQuery(fsp.indexingParams, mainQuery);
List<CategoryPath> paths = new ArrayList<CategoryPath>();
...
add category path
...
if (paths.size() >0)
ddq.add(paths.toArray(new CategoryPath[paths.size()]));
DrillSidewaysResult dsr = ds.search(null, ddq, 500, fsp); // <-- here
TopDocs topDocs = dsr.hits;
ScoreDoc[] hits = topDocs.scoreDocs;
// list search results
listSearchResults(searcher, hits, Math.min(500, topDocs.totalHits));
但是,如果我想传递TopScoreDocCollector,如
,该怎么办?// for now it is top score collector,
// but I may want to implement custom sort
TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(500, true);
DrillSidewaysResult dsr = ds.search(ddq, topDocsCollector, fsp);
结果是空集并且没有错误。有什么问题?
答案 0 :(得分:0)
我猜你指的是DrillSidewaysResult.hits
的价值,它是预期的行为,如DrillSidewaysResult
的文档中所述:
请注意,如果您调用DrillSideways.search(DrillDownQuery,Collector,FacetSearchParams),则匹配将为null。
您应该从Collector
获得点击量。