org.weborganic.bastille.flint.helpers
Class MultipleIndex

java.lang.Object
  extended by org.weborganic.bastille.flint.helpers.MultipleIndex

public final class MultipleIndex
extends Object

Handles multiple Index Masters, each master is specified by its index directory.

Since:
0.6.18

Nested Class Summary
 class MultipleIndex.MultipleIndexReader
          Handle a list of readers.
 
Constructor Summary
MultipleIndex(List<File> indexDirectories)
          Build a new multiple index.
 
Method Summary
 List<Facet> getFacets(List<String> fields, int upTo, Query query)
          Returns the list of term and how frequently they are used by performing a fuzzy match on the specified term.
static IndexMaster getMaster(File index)
          Deprecated. Use getMaster(File) instead
 MultipleIndex.MultipleIndexReader getMultiReader()
           
 MultiSearchResults query(SearchQuery query)
          Perform a query on multiple indexes.
 MultiSearchResults query(SearchQuery query, SearchPaging paging)
          Perform a query on multiple indexes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipleIndex

public MultipleIndex(List<File> indexDirectories)
Build a new multiple index.

Parameters:
indexDirectories - the root folders for all indexes
Method Detail

getMaster

@Deprecated
public static IndexMaster getMaster(File index)
Deprecated. Use getMaster(File) instead

Parameters:
index - The directory for the index to return
Returns:
the master for the given index root

query

public MultiSearchResults query(SearchQuery query)
                         throws IndexException
Perform a query on multiple indexes.

Note that all the indexes MUST be initialized before calling this method.

Parameters:
query - the query to perform.
Returns:
The search results
Throws:
IndexException - If the query failed
IllegalStateException - If one of the indexes is not initialized

query

public MultiSearchResults query(SearchQuery query,
                                SearchPaging paging)
                         throws IndexException
Perform a query on multiple indexes.

Note that all the indexes MUST be initialised before calling this method.

Parameters:
query - the query to perform.
paging - the paging mechanism
Returns:
The search results
Throws:
IndexException - If the query failed
IllegalStateException - If one of the indexes is not initialised

getFacets

public List<Facet> getFacets(List<String> fields,
                             int upTo,
                             Query query)
                      throws IOException,
                             IndexException
Returns the list of term and how frequently they are used by performing a fuzzy match on the specified term.

Parameters:
fields - the fields to use as facets
upTo - the max number of values to return
query - a predicate to apply on the facet (can be null or empty)
Throws:
IndexException - if there was an error reading the indexes or creating the condition query
IllegalStateException - If one of the indexes is not initialised
IOException

getMultiReader

public MultipleIndex.MultipleIndexReader getMultiReader()
Returns:
a new reader reading all indexes.