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 close()
          Closes and disposes of the search engine.
protected  void closeDelegateClosed()
           
 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.
 void delete(SearchEngineQuery query)
          Deletes all the resources that match the provided query.
 SearchEngineHits find(SearchEngineQuery query)
           
 void flush()
          Flushes the current transaction.
 void flushCommit(String... aliases)
          Flushes the current transaction, and make all the operations perfomed on it until now "viewable" to other transactions.
 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()
          Returns the runtime settings of the session / search engine.
 TransactionProcessor getTransactionProcessor()
           
 SearchEngineInternalSearch internalSearch(String[] subIndexes, String[] aliases)
          Returns a search engine internal implementation.
 boolean isReadOnly()
          Returns true if the session is read only.
 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.
 boolean onlyReadOperations()
          Returns true if the search engine was used (up until now) for read only operations.
 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.
 void setReadOnly()
          Indicates that the search engine will be used for read only operations.
 SearchEngineTermFrequencies termFreq(String[] propertyNames, int size, SearchEngineInternalSearch internalSearch)
          Returns term frequencies.
 void verifyNotReadOnly()
           
 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

setReadOnly

public void setReadOnly()
Description copied from interface: SearchEngine
Indicates that the search engine will be used for read only operations. Allowing to optimize search and read.

Specified by:
setReadOnly in interface SearchEngine

isReadOnly

public boolean isReadOnly()
Description copied from interface: SearchEngine
Returns true if the session is read only.

Specified by:
isReadOnly in interface SearchEngine
See Also:
SearchEngine.setReadOnly()

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

verifyNotReadOnly

public void verifyNotReadOnly()
                       throws SearchEngineException
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
Flushes the current transaction. Tries to wait till all operations are applied to the index.

Specified by:
flush in interface SearchEngine
Throws:
SearchEngineException

flushCommit

public void flushCommit(String... aliases)
                 throws SearchEngineException
Description copied from interface: SearchEngine
Flushes the current transaction, and make all the operations perfomed on it until now "viewable" to other transactions. The operations performed before the flush commit operation will not rollback on rollback operation.

Specified by:
flushCommit 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

delete

public void delete(SearchEngineQuery query)
            throws SearchEngineException
Description copied from interface: SearchEngine
Deletes all the resources that match the provided query.

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)

closeDelegateClosed

protected void closeDelegateClosed()
                            throws SearchEngineException
Throws:
SearchEngineException

getSearchEngineFactory

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

getTransactionProcessor

public TransactionProcessor getTransactionProcessor()

getSettings

public CompassSettings getSettings()
Returns the runtime settings of the session / search engine.


onlyReadOperations

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

Specified by:
onlyReadOperations in interface SearchEngine


Copyright (c) 2004-2009 The Compass Project.