org.compass.core.lucene.engine.spellcheck
Class DefaultLuceneSpellCheckManager

java.lang.Object
  extended by org.compass.core.lucene.engine.spellcheck.DefaultLuceneSpellCheckManager
All Implemented Interfaces:
SearchEngineSpellCheckManager, InternalSearchEngineSpellCheckManager, InternalLuceneSearchEngineSpellCheckManager

public class DefaultLuceneSpellCheckManager
extends Object
implements InternalLuceneSearchEngineSpellCheckManager

The default implementation of the search engine spell check manager. Uses Lucene (modified) spell check support. Only activated if the spell jar exists.

Author:
kimchy

Field Summary
static String SPELL_CHECK_VERSION_FILENAME
           
 
Constructor Summary
DefaultLuceneSpellCheckManager()
           
 
Method Summary
 void close()
          Closes the given spell check manager.
 boolean concurrentRebuild()
          Same as SearchEngineSpellCheckManager.rebuild() but executes the rebuild of each sub index using Compass built in thread pool
 void concurrentRefresh()
          Same as SearchEngineSpellCheckManager.refresh() but executes the refresh of each sub index using Compass built in thread pool.
 void configure(LuceneSearchEngineFactory searchEngineFactory, CompassSettings settings, CompassMapping mapping)
           
 CompassSpellChecker createSpellChecker(String[] subIndexes, String[] aliases)
           
 void deleteIndex()
          Deletes the spell check index.
 void deleteIndex(String subIndex)
          Deletes the spell check index for the given sub index.
<T> T
execute(String[] subIndexes, String[] aliases, SpellCheckerCallback<T> callback)
           
 float getDefaultAccuracy()
           
 int getDefaultNumberOfSuggestions()
           
 String getDefaultProperty()
           
 CompassMapping getMapping()
           
 boolean isRebuildNeeded()
          Returns true if a rebuild of the spell check index is required.
 boolean isRebuildNeeded(String subIndex)
          Returns true if a rebuild of the spell index for the given sub index is required.
 boolean rebuild()
          Rebuilds the spell check index.
 boolean rebuild(String subIndex)
          Rebuilds the spell check index for the given sub index.
 void refresh()
          Refresh the internal readers and searches that work with the spell index.
 void refresh(String subIndex)
          Refresh the internal readers and searches for the given sub index that work with the spell index.
 void start()
          Starts the spell check manager.
 void stop()
          Stops any scheduled tasks started by the SearchEngineSpellCheckManager.start() method.
 CompassQuery suggest(CompassQuery query)
          Suggests a query based on the given query.
 SearchEngineSpellCheckSuggestBuilder suggestBuilder(String word)
          Creates a suggest builder allowing to suggest words for the given word.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPELL_CHECK_VERSION_FILENAME

public static String SPELL_CHECK_VERSION_FILENAME
Constructor Detail

DefaultLuceneSpellCheckManager

public DefaultLuceneSpellCheckManager()
Method Detail

configure

public void configure(LuceneSearchEngineFactory searchEngineFactory,
                      CompassSettings settings,
                      CompassMapping mapping)
Specified by:
configure in interface InternalLuceneSearchEngineSpellCheckManager

start

public void start()
Description copied from interface: SearchEngineSpellCheckManager
Starts the spell check manager. Will start a scheduled task to refresh the cached searchers and readers over the spell check index. Will also schedule, if configured, a schediled rebuild of the spell check index.

Specified by:
start in interface SearchEngineSpellCheckManager

stop

public void stop()
Description copied from interface: SearchEngineSpellCheckManager
Stops any scheduled tasks started by the SearchEngineSpellCheckManager.start() method.

Specified by:
stop in interface SearchEngineSpellCheckManager

close

public void close()
Description copied from interface: InternalSearchEngineSpellCheckManager
Closes the given spell check manager.

Specified by:
close in interface InternalSearchEngineSpellCheckManager

getDefaultProperty

public String getDefaultProperty()
Specified by:
getDefaultProperty in interface InternalLuceneSearchEngineSpellCheckManager

getDefaultAccuracy

public float getDefaultAccuracy()
Specified by:
getDefaultAccuracy in interface InternalLuceneSearchEngineSpellCheckManager

getDefaultNumberOfSuggestions

public int getDefaultNumberOfSuggestions()
Specified by:
getDefaultNumberOfSuggestions in interface InternalLuceneSearchEngineSpellCheckManager

getMapping

public CompassMapping getMapping()
Specified by:
getMapping in interface InternalLuceneSearchEngineSpellCheckManager

concurrentRefresh

public void concurrentRefresh()
                       throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Same as SearchEngineSpellCheckManager.refresh() but executes the refresh of each sub index using Compass built in thread pool.

Specified by:
concurrentRefresh in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

refresh

public void refresh()
             throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Refresh the internal readers and searches that work with the spell index.

Specified by:
refresh in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

refresh

public void refresh(String subIndex)
             throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Refresh the internal readers and searches for the given sub index that work with the spell index.

Specified by:
refresh in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

isRebuildNeeded

public boolean isRebuildNeeded()
                        throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Returns true if a rebuild of the spell check index is required.

Specified by:
isRebuildNeeded in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

isRebuildNeeded

public boolean isRebuildNeeded(String subIndex)
                        throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Returns true if a rebuild of the spell index for the given sub index is required.

Specified by:
isRebuildNeeded in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

concurrentRebuild

public boolean concurrentRebuild()
                          throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Same as SearchEngineSpellCheckManager.rebuild() but executes the rebuild of each sub index using Compass built in thread pool

Specified by:
concurrentRebuild in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

rebuild

public boolean rebuild()
                throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Rebuilds the spell check index. Won't rebuild specific sub indexes if it is not needed.

Specified by:
rebuild in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

rebuild

public boolean rebuild(String subIndex)
                throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Rebuilds the spell check index for the given sub index. Won't rebuild if it is not needed.

Specified by:
rebuild in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

deleteIndex

public void deleteIndex()
                 throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Deletes the spell check index.

Specified by:
deleteIndex in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

deleteIndex

public void deleteIndex(String subIndex)
                 throws SearchEngineException
Description copied from interface: SearchEngineSpellCheckManager
Deletes the spell check index for the given sub index.

Specified by:
deleteIndex in interface SearchEngineSpellCheckManager
Throws:
SearchEngineException

suggestBuilder

public SearchEngineSpellCheckSuggestBuilder suggestBuilder(String word)
Description copied from interface: SearchEngineSpellCheckManager
Creates a suggest builder allowing to suggest words for the given word.

Specified by:
suggestBuilder in interface SearchEngineSpellCheckManager

suggest

public CompassQuery suggest(CompassQuery query)
Description copied from interface: SearchEngineSpellCheckManager
Suggests a query based on the given query. Note, if the query was replaced/sugested then the CompassQuery.isSuggested() flag will be set to true.

Specified by:
suggest in interface SearchEngineSpellCheckManager

execute

public <T> T execute(String[] subIndexes,
                     String[] aliases,
                     SpellCheckerCallback<T> callback)
Specified by:
execute in interface InternalLuceneSearchEngineSpellCheckManager

createSpellChecker

public CompassSpellChecker createSpellChecker(String[] subIndexes,
                                              String[] aliases)
Specified by:
createSpellChecker in interface InternalLuceneSearchEngineSpellCheckManager


Copyright (c) 2004-2008 The Compass Project.