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.
 Property createProperty(String name, byte[] value, Property.Store store)
          Creates a binary property.
 Property createProperty(String name, Reader value)
          Creates a property (TEXT type) for the specified reader.
 Property createProperty(String name, Reader value, Property.TermVector termVector)
          Creates a property (indexed, and not stored) for the specified reader.
 Property createProperty(String value, ResourcePropertyMapping mapping)
          Creates a Property that is used with the actual Search Engine
 Property createProperty(String value, ResourcePropertyMapping mapping, Property.Store store, Property.Index index)
           
 Property createProperty(String name, String value, Property.Store store, Property.Index index)
          Creates a Property that is used with the actual Search Engine
 Property createProperty(String name, String value, Property.Store store, Property.Index index, Property.TermVector termVector)
          Creates a Property that is used with the actual Search Engine.
 Property createProperty(String name, String value, ResourcePropertyMapping mapping)
          Creates a Property that is used with the actual Search Engine
 Property createProperty(String name, String value, ResourcePropertyMapping mapping, Property.Store store, Property.Index index)
           
 Resource createResource(String alias)
          Creates a resource, that is used with the actual Search Engine implementation.
 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.
 String getNullValue()
          Returns a null value that represents no entry in the search engine.
 LuceneSearchEngineFactory getSearchEngineFactory()
           
 CompassSettings getSettings()
           
 SearchEngineInternalSearch internalSearch(String[] subIndexes, String[] aliases)
          Returns a search engine internal implementation.
 boolean isNullValue(String value)
          Returns true if the value is marked as a null value.
 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 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

getNullValue

public String getNullValue()
Description copied from interface: SearchEngine
Returns a null value that represents no entry in the search engine. Usefull when the system needs to store an actual data entry, but for it to represent a business null value.

Specified by:
getNullValue in interface SearchEngine

isNullValue

public boolean isNullValue(String value)
Description copied from interface: SearchEngine
Returns true if the value is marked as a null value.

Specified by:
isNullValue in interface SearchEngine

createResource

public Resource createResource(String alias)
                        throws SearchEngineException
Description copied from interface: SearchEngine
Creates a resource, that is used with the actual Search Engine implementation.

Specified by:
createResource in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String value,
                               ResourcePropertyMapping mapping)
                        throws SearchEngineException
Description copied from interface: SearchEngine
Creates a Property that is used with the actual Search Engine

Specified by:
createProperty in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String value,
                               ResourcePropertyMapping mapping,
                               Property.Store store,
                               Property.Index index)
                        throws SearchEngineException
Specified by:
createProperty in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String name,
                               String value,
                               ResourcePropertyMapping mapping)
                        throws SearchEngineException
Description copied from interface: SearchEngine
Creates a Property that is used with the actual Search Engine

Specified by:
createProperty in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String name,
                               String value,
                               ResourcePropertyMapping mapping,
                               Property.Store store,
                               Property.Index index)
                        throws SearchEngineException
Throws:
SearchEngineException

createProperty

public Property createProperty(String name,
                               String value,
                               Property.Store store,
                               Property.Index index)
                        throws SearchEngineException
Description copied from interface: SearchEngine
Creates a Property that is used with the actual Search Engine

Specified by:
createProperty in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String name,
                               String value,
                               Property.Store store,
                               Property.Index index,
                               Property.TermVector termVector)
                        throws SearchEngineException
Description copied from interface: SearchEngine
Creates a Property that is used with the actual Search Engine. The available values for the store and index parameters are provided in the Property interface (Property.Store, Property.Index, Property.TermVector).

Specified by:
createProperty in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String name,
                               Reader value)
Description copied from interface: SearchEngine
Creates a property (TEXT type) for the specified reader.

Specified by:
createProperty in interface SearchEngine

createProperty

public Property createProperty(String name,
                               byte[] value,
                               Property.Store store)
                        throws SearchEngineException
Description copied from interface: SearchEngine
Creates a binary property.

Specified by:
createProperty in interface SearchEngine
Throws:
SearchEngineException

createProperty

public Property createProperty(String name,
                               Reader value,
                               Property.TermVector termVector)
Description copied from interface: SearchEngine
Creates a property (indexed, and not stored) for the specified reader.

Specified by:
createProperty in interface SearchEngine

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

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

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

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

getSearchEngineFactory

public LuceneSearchEngineFactory getSearchEngineFactory()

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-2006 The Compass Project.