Performance “如何过滤掉”;点击;indexsearcher.search()函数返回的结果?

Performance “如何过滤掉”;点击;indexsearcher.search()函数返回的结果?,performance,lucene,indexing,confluence,Performance,Lucene,Indexing,Confluence,如何减小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)){

如何减小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”或“Collector”的东西,它应该有助于提高性能,但我不知道如何使用它

如果有人能给我指出正确的方向,我将不胜感激


我们正在使用Apache Lucene在Atlassian Confluence web应用程序中编制索引。

为了获得良好的性能,您必须为每个文档的安全信息编制索引。这当然取决于您的安全模型。例如,如果您可以将每个文档分配给具有权限的安全角色,则可以使用该安全角色。阿尔索
退房您的收集器与此几乎是重复的。

收集器只是一种简单的回调机制,每次点击文档时都会调用它,您可以使用如下收集器:-

public class MyCollector extends HitCollector {

// this is called back for every document that 
// matches, with the docid and the score

public void collect(int doc, float score){

    // do whatever you have to in here

}
}

..

HitCollector collector = new MyCollector();

indexSearch(query,filter,collector);