and another question, is it somehow possible to reuse TopScoreDocCollector instance?
Javadoc in create(...) warns about allocating full array. <p><b>NOTE</b>: The instances returned by this method * pre-allocate a full array of length * <code>numHits</code>, and fill the array with sentinel * objects. ----- Original Message ---- > From: eks dev <eks...@yahoo.co.uk> > To: java-user@lucene.apache.org > Sent: Wednesday, 30 September, 2009 11:43:26 > Subject: TSDC, TopFieldCollector & co > > Hi All, > > What is the best way to achieve the following and what are the differences, > if I > say "I do not normalize scores, so I do not need max score tracking, I do not > care if hits are returned in doc id order, or any other order. I need only to > get maxDocs *best scoring* documents": > > OPTION 1: > TopDocs top = ixSearcher.search(q, filter, maxDocs); > > OPTION 2: > final TopScoreDocCollector tfc = TopScoreDocCollector.create(maxDocs, > false); > ixSearcher.search(q, filter, tfc); > TopDocs top = tfc.topDocs(); > > > OPTION 3: > final TopFieldCollector tfc = TopFieldCollector.create(Sort.RELEVANCE, > maxDocs, > false /* fillFields */, > true /* trackDocScores */, > false /* trackMaxScore */, > false /* docsInOrder */); > > ixSearcher.search(q.weight(ixSearcher),filter, tfc); > TopDocs top = tfc.topDocs(); > > > what are the pros and cons? > If I read javadoc correctly, > - OPTION 1 tracks max score and delivers doc Ids in order (suboptimal > performance for my case) > - OPTION 2 I do not know abut max score tracking, but doc Ids are not > required > to be in order > - OPTION 3 looks like exactly what I want, but one performance comment in > javadoc about Sort.RELEVANCE made me think if that is the fastest way? > > What would be recommended here, any other options to achieve the fastest > search > with above defined conditions (no max score tracking and doc id order > irrelevant)? OPTIN2 looks nice, but as said, I am not sure about max score > tracking? > > Thanks, > eks > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org