如何縮小由indexsearcher.search()函數返回的「Hits」對象的大小?如何濾除indexsearcher.search()函數返回的結果「Hits」?
目前,我做這樣的事情:
Hits hits = indexSearch.search(query,filter,...);
Iterator hitsIt = hits.iterator();
int newSize=0;
while (hitsIt.hasNext()){
Hit currHit = (Hit)hitsIt.next();
if (hasPermission(currHit)){
newSize++;
}
}
然而,這創造了巨大的性能問題時命中的數量較大(如500或更多)。
我聽說過所謂的「HitsCollector」或可能是「收藏家」,這應該有助於提高性能,但我不知道如何使用它。
如果有人能指出我正確的方向,我將不勝感激。
我們在Atlassian Confluence web應用程序中使用Apache Lucene進行索引。