com.atlassian.confluence.search.v2.lucene.resultfilter
Class LuceneHandleBasedSubsetResultFilter

java.lang.Object
  extended by com.atlassian.confluence.search.v2.lucene.resultfilter.LuceneHandleBasedSubsetResultFilter
All Implemented Interfaces:
LuceneResultFilter, InitializationRequired

public class LuceneHandleBasedSubsetResultFilter
extends java.lang.Object
implements LuceneResultFilter, InitializationRequired

A result filter used for pagination of SearchResultType.CHANGE documents.

It allows clients to ask for a page of results that begins at a particular result (identified using a Handle).

For performance reasons, this filter can only return a subset within the bounds of MAX_HITS_TO_SEARCH. That is, if you request a handle ranked just 5 pages before the limit and a page size of 10, you will only get 5 results. Similarly, requesting a handle that is ranked beyond the limit will return an empty subset.

WARNING: Do not reuse this filter outside of the search it was originally created for.


Field Summary
static int MAX_HITS_TO_SEARCH
          Sets a maximum to the number of hits this filter will iterate over to find the handle.
 
Constructor Summary
LuceneHandleBasedSubsetResultFilter(com.atlassian.bonnie.Handle startHandle, int pageSize)
           
 
Method Summary
 int getExpectedResultsCount()
          The number of results that the filter expects to allow into the final search result.
 void init(org.apache.lucene.index.IndexReader indexReader)
          Performs initialisation of a result filter using the indexReader provided.
 boolean isIncludedInResults(WrappedHit hit)
           
 boolean isInitialized()
           
 boolean shouldContinueIterating()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_HITS_TO_SEARCH

public static final int MAX_HITS_TO_SEARCH
Sets a maximum to the number of hits this filter will iterate over to find the handle. This is to protect against the filter searching the whole index for a handle that may or may not exist.

We want to limit this to 200, because our use of the Hits object makes it expensive to ask for a large body of results. For example, requesting 200 results costs 2 searches and 400 results costs 3 searches. We currently consider 2 searches an acceptable cost to allow clients access to more results (up to 200 anyway).

See Also:
Constant Field Values
Constructor Detail

LuceneHandleBasedSubsetResultFilter

public LuceneHandleBasedSubsetResultFilter(com.atlassian.bonnie.Handle startHandle,
                                           int pageSize)
Method Detail

init

public void init(org.apache.lucene.index.IndexReader indexReader)
Description copied from interface: InitializationRequired
Performs initialisation of a result filter using the indexReader provided.

Specified by:
init in interface InitializationRequired
Parameters:
indexReader - the indexReader owned by the IndexSearcher used by the search.

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface InitializationRequired
Returns:
true if initialisation succeeded, false otherwise.

isIncludedInResults

public boolean isIncludedInResults(WrappedHit hit)
Specified by:
isIncludedInResults in interface LuceneResultFilter

shouldContinueIterating

public boolean shouldContinueIterating()
Specified by:
shouldContinueIterating in interface LuceneResultFilter

getExpectedResultsCount

public int getExpectedResultsCount()
Description copied from interface: LuceneResultFilter
The number of results that the filter expects to allow into the final search result. This is used as a purely advisory number to initialise the size of collections, and so on. Returning a number less than or equal to zero indicates that the filter has no idea how many results it is likely to return.

Specified by:
getExpectedResultsCount in interface LuceneResultFilter
Returns:
the number of results the filter expects to permit in the search results, or zero if no prediction can be made.


Copyright © 2003-2010 Atlassian. All Rights Reserved.