org.compass.core.lucene.engine
Class LuceneSearchEngine

java.lang.Object
  extended by org.compass.core.lucene.engine.LuceneSearchEngine
All Implemented Interfaces:
SearchEngine

public class LuceneSearchEngine
extends Object
implements SearchEngine

Author:
kimchy

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
LuceneSearchEngine(RuntimeCompassSettings runtimeSettings, LuceneSearchEngineFactory searchEngineFactory)
           
 
Method Summary
 SearchEngineAnalyzerHelper analyzerHelper()
          Returns an analyzer helper for the search engine.
 void begin()
          Begins the search engine transaction, using the configured transaction isolation.
 void begin(CompassTransaction.TransactionIsolation transactionIsolation)
          Begins the search engine transaction using the given transaction isolation.
 void close()
          Closes and disposes of the search engine.
 void commit(boolean onePhase)
          Commits the transaction.
 void create(Resource resource)
          Creates the resource in the index file under the given alias.
 void delete(Resource resource)
          Deletes the resource, which has the property ids.
 SearchEngineHits find(SearchEngineQuery query)
           
 void flush()
          Flushed the current transaction.
 Resource get(Resource idResource)
          Returns a resource for the given resource that holds the properties AND the alias, under the specified alias.
 LuceneSearchEngineFactory getSearchEngineFactory()
           
 CompassSettings getSettings()
           
 SearchEngineInternalSearch internalSearch(String[] subIndexes, String[] aliases)
          Returns a search engine internal implementation.
 boolean isReadOnly()
          Returns true if the search engine was used (up until now) for read only operations.
 boolean isWithinTransaction()
          Returns true if Compass is within a running transaction.
 Resource load(Resource idResource)
          Loads a resource for the given resource that holds the properties AND the alias, under the specified alias.
 void prepare()
          Prepares the transaction for a commit.
 SearchEngineQueryBuilder queryBuilder()
          Creates a new query builder.
 SearchEngineQueryFilterBuilder queryFilterBuilder()
          Creates a new query filter builder.
 void removeDelegatedClose(LuceneDelegatedClose closable)
           
 void rollback()
          Rolls back the current transaction.
 void save(Resource resource)
          Saves the given resource under the given resource.
 SearchEngineTermFrequencies termFreq(String[] propertyNames, int size, SearchEngineInternalSearch internalSearch)
          Returns term frequencies.
 void verifyWithinTransaction()
           
 boolean wasCommitted()
          Check if this transaction was successfully committed.
 boolean wasRolledBack()
          Was this transaction rolled back
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

LuceneSearchEngine

public LuceneSearchEngine(RuntimeCompassSettings runtimeSettings,
                          LuceneSearchEngineFactory searchEngineFactory)
Method Detail

queryBuilder

public SearchEngineQueryBuilder queryBuilder()
                                      throws SearchEngineException
Description copied from interface: SearchEngine
Creates a new query builder.

Specified by:
queryBuilder in interface SearchEngine
Throws:
SearchEngineException

queryFilterBuilder

public SearchEngineQueryFilterBuilder queryFilterBuilder()
                                                  throws SearchEngineException
Description copied from interface: SearchEngine
Creates a new query filter builder.

Specified by:
queryFilterBuilder in interface SearchEngine
Throws:
SearchEngineException

analyzerHelper

public SearchEngineAnalyzerHelper analyzerHelper()
Description copied from interface: SearchEngine
Returns an analyzer helper for the search engine.

Specified by:
analyzerHelper in interface SearchEngine

begin

public void begin()
           throws SearchEngineException
Description copied from interface: SearchEngine
Begins the search engine transaction, using the configured transaction isolation.

Specified by:
begin in interface SearchEngine
Throws:
SearchEngineException

begin

public void begin(CompassTransaction.TransactionIsolation transactionIsolation)
           throws SearchEngineException
Description copied from interface: SearchEngine
Begins the search engine transaction using the given transaction isolation.

Specified by:
begin in interface SearchEngine
Throws:
SearchEngineException

verifyWithinTransaction

public void verifyWithinTransaction()
                             throws SearchEngineException
Throws:
SearchEngineException

isWithinTransaction

public boolean isWithinTransaction()
                            throws SearchEngineException
Description copied from interface: SearchEngine
Returns true if Compass is within a running transaction.

Specified by:
isWithinTransaction in interface SearchEngine
Throws:
SearchEngineException

prepare

public void prepare()
             throws SearchEngineException
Description copied from interface: SearchEngine
Prepares the transaction for a commit. The first phase of a two phase commit operation.

Specified by:
prepare in interface SearchEngine
Throws:
SearchEngineException

commit

public void commit(boolean onePhase)
            throws SearchEngineException
Description copied from interface: SearchEngine
Commits the transaction. If onePhase is set to true, commits the transaction by executing the two phases in the two phase commit operation. If it is set to false, executes the second phase of the two phase commit operation (and must be called after prepare).

Specified by:
commit in interface SearchEngine
Throws:
SearchEngineException

rollback

public void rollback()
              throws SearchEngineException
Description copied from interface: SearchEngine
Rolls back the current transaction. Can be called before any phase of the commit operation was executed, and after the first phase of the two phase commit operation (the prepare operation).

Specified by:
rollback in interface SearchEngine
Throws:
SearchEngineException

flush

public void flush()
           throws SearchEngineException
Description copied from interface: SearchEngine
Flushed the current transaction. Currently only works with batch insert transaction.

Specified by:
flush in interface SearchEngine
Throws:
SearchEngineException

wasRolledBack

public boolean wasRolledBack()
                      throws SearchEngineException
Description copied from interface: SearchEngine
Was this transaction rolled back

Specified by:
wasRolledBack in interface SearchEngine
Throws:
SearchEngineException

wasCommitted

public boolean wasCommitted()
                     throws SearchEngineException
Description copied from interface: SearchEngine
Check if this transaction was successfully committed. This method could return false even after successful invocation of commit().

Specified by:
wasCommitted in interface SearchEngine
Throws:
SearchEngineException

close

public void close()
           throws SearchEngineException
Description copied from interface: SearchEngine
Closes and disposes of the search engine.

Specified by:
close in interface SearchEngine
Throws:
SearchEngineException

delete

public void delete(Resource resource)
            throws SearchEngineException
Description copied from interface: SearchEngine
Deletes the resource, which has the property ids. The ResourceMapping is fetched according to the alias.

Specified by:
delete in interface SearchEngine
Throws:
SearchEngineException

save

public void save(Resource resource)
          throws SearchEngineException
Description copied from interface: SearchEngine
Saves the given resource under the given resource.

Specified by:
save in interface SearchEngine
Throws:
SearchEngineException

create

public void create(Resource resource)
            throws SearchEngineException
Description copied from interface: SearchEngine
Creates the resource in the index file under the given alias.

Specified by:
create in interface SearchEngine
Throws:
SearchEngineException

get

public Resource get(Resource idResource)
             throws SearchEngineException
Description copied from interface: SearchEngine
Returns a resource for the given resource that holds the properties AND the alias, under the specified alias. Retrurns null if the resource is not found.

Specified by:
get in interface SearchEngine
Throws:
SearchEngineException

load

public Resource load(Resource idResource)
              throws SearchEngineException
Description copied from interface: SearchEngine
Loads a resource for the given resource that holds the properties AND the alias, under the specified alias. Throws an exception if the resource if not found.

Specified by:
load in interface SearchEngine
Throws:
SearchEngineException

find

public SearchEngineHits find(SearchEngineQuery query)
                      throws SearchEngineException
Throws:
SearchEngineException

termFreq

public SearchEngineTermFrequencies termFreq(String[] propertyNames,
                                            int size,
                                            SearchEngineInternalSearch internalSearch)
Description copied from interface: SearchEngine
Returns term frequencies.

Specified by:
termFreq in interface SearchEngine

internalSearch

public SearchEngineInternalSearch internalSearch(String[] subIndexes,
                                                 String[] aliases)
                                          throws SearchEngineException
Description copied from interface: SearchEngine
Returns a search engine internal implementation.

Specified by:
internalSearch in interface SearchEngine
Throws:
SearchEngineException

removeDelegatedClose

public void removeDelegatedClose(LuceneDelegatedClose closable)

getSearchEngineFactory

public LuceneSearchEngineFactory getSearchEngineFactory()
Specified by:
getSearchEngineFactory in interface SearchEngine

getSettings

public CompassSettings getSettings()

isReadOnly

public boolean isReadOnly()
Description copied from interface: SearchEngine
Returns true if the search engine was used (up until now) for read only operations.

Specified by:
isReadOnly in interface SearchEngine


Copyright (c) 2004-2008 The Compass Project.