org.compass.core.engine
Interface SearchEngine

All Known Implementing Classes:
LuceneSearchEngine

public interface SearchEngine

A search engine absraction above the actual search engine implementation. Works with resources and properties for data, and ResourceMapping, PropertyMapping, and ResourceIdMapping.

All the search engine operations the are needed should be provided by the SearchEngine abstraction (save, delete, load, get, find).

The search engine abstraction also acts as a Property and Resource factory, creating the actual implementations.

The search engine must provide supprot for transactional operations, though in practice, it can be a non transactional search engine. If it is a non transactional search engine, it must be documented as such.

Author:
kimchy
See Also:
Resource, Property, ResourceMapping, ResourcePropertyMapping, ResourceIdMappingProvider

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.
 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.
 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.
 SearchEngineFactory getSearchEngineFactory()
           
 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 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.
 boolean wasCommitted()
          Check if this transaction was successfully committed.
 boolean wasRolledBack()
          Was this transaction rolled back
 

Method Detail

getSearchEngineFactory

SearchEngineFactory getSearchEngineFactory()

setReadOnly

void setReadOnly()
Indicates that the search engine will be used for read only operations. Allowing to optimize search and read.


isReadOnly

boolean isReadOnly()
Returns true if the session is read only.

See Also:
setReadOnly()

onlyReadOperations

boolean onlyReadOperations()
Returns true if the search engine was used (up until now) for read only operations.


begin

void begin()
           throws SearchEngineException
Begins the search engine transaction, using the configured transaction isolation.

Throws:
SearchEngineException

prepare

void prepare()
             throws SearchEngineException
Prepares the transaction for a commit. The first phase of a two phase commit operation.

Throws:
SearchEngineException

commit

void commit(boolean onePhase)
            throws SearchEngineException
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).

Throws:
SearchEngineException

isWithinTransaction

boolean isWithinTransaction()
                            throws SearchEngineException
Returns true if Compass is within a running transaction.

Throws:
SearchEngineException

rollback

void rollback()
              throws SearchEngineException
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).

Throws:
SearchEngineException

flush

void flush()
           throws SearchEngineException
Flushes the current transaction. Tries to wait till all operations are applied to the index.

Throws:
SearchEngineException

flushCommit

void flushCommit(String... aliases)
                 throws SearchEngineException
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.

Throws:
SearchEngineException

wasRolledBack

boolean wasRolledBack()
                      throws SearchEngineException
Was this transaction rolled back

Throws:
SearchEngineException

wasCommitted

boolean wasCommitted()
                     throws SearchEngineException
Check if this transaction was successfully committed. This method could return false even after successful invocation of commit().

Throws:
SearchEngineException

close

void close()
           throws SearchEngineException
Closes and disposes of the search engine.

Throws:
SearchEngineException

queryBuilder

SearchEngineQueryBuilder queryBuilder()
                                      throws SearchEngineException
Creates a new query builder.

Throws:
SearchEngineException

queryFilterBuilder

SearchEngineQueryFilterBuilder queryFilterBuilder()
                                                  throws SearchEngineException
Creates a new query filter builder.

Throws:
SearchEngineException

analyzerHelper

SearchEngineAnalyzerHelper analyzerHelper()
Returns an analyzer helper for the search engine.


create

void create(Resource resource)
            throws SearchEngineException
Creates the resource in the index file under the given alias.

Throws:
SearchEngineException

save

void save(Resource resource)
          throws SearchEngineException
Saves the given resource under the given resource.

Throws:
SearchEngineException

delete

void delete(Resource resource)
            throws SearchEngineException
Deletes the resource, which has the property ids. The ResourceMapping is fetched according to the alias.

Throws:
SearchEngineException

delete

void delete(SearchEngineQuery query)
            throws SearchEngineException
Deletes all the resources that match the provided query.

Throws:
SearchEngineException

load

Resource load(Resource idResource)
              throws SearchEngineException
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.

Throws:
SearchEngineException

get

Resource get(Resource idResource)
             throws SearchEngineException
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.

Throws:
SearchEngineException

termFreq

SearchEngineTermFrequencies termFreq(String[] propertyNames,
                                     int size,
                                     SearchEngineInternalSearch internalSearch)
Returns term frequencies.


internalSearch

SearchEngineInternalSearch internalSearch(String[] subIndexes,
                                          String[] aliases)
                                          throws SearchEngineException
Returns a search engine internal implementation.

Throws:
SearchEngineException


Copyright (c) 2004-2009 The Compass Project.