草庐IT

TopDocCollector

全部标签

java - 从命中/命中迁移到 TopDocs/TopDocCollector

我有这样的现有代码:finalTermt=/*...*/;finalIteratori=searcher.search(newTermQuery(t)).iterator();while(i.hasNext()){Hithit=(Hit)i.next();//"FILE"isthefieldthatrecordedtheoriginalfileindexedFilef=newFile(hit.get("FILE"));//...}我不清楚如何使用TopDocs/TopDocCollector重写代码以及如何迭代所有结果。 最佳答案