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

Method Detail

getNullValue

String getNullValue()
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.


isNullValue

boolean isNullValue(String value)
Returns true if the value is marked as a null value.


createResource

Resource createResource(String alias)
                        throws SearchEngineException
Creates a resource, that is used with the actual Search Engine implementation.

Throws:
SearchEngineException

createProperty

Property createProperty(String value,
                        ResourcePropertyMapping mapping)
                        throws SearchEngineException
Creates a Property that is used with the actual Search Engine

Throws:
SearchEngineException

createProperty

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

createProperty

Property createProperty(String name,
                        String value,
                        ResourcePropertyMapping mapping)
                        throws SearchEngineException
Creates a Property that is used with the actual Search Engine

Throws:
SearchEngineException

createProperty

Property createProperty(String name,
                        String value,
                        Property.Store store,
                        Property.Index index)
                        throws SearchEngineException
Creates a Property that is used with the actual Search Engine

Throws:
SearchEngineException

createProperty

Property createProperty(String name,
                        String value,
                        Property.Store store,
                        Property.Index index,
                        Property.TermVector termVector)
                        throws SearchEngineException
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).

Throws:
SearchEngineException

createProperty

Property createProperty(String name,
                        Reader value)
                        throws SearchEngineException
Creates a property (TEXT type) for the specified reader.

Throws:
SearchEngineException

createProperty

Property createProperty(String name,
                        Reader value,
                        Property.TermVector termVector)
                        throws SearchEngineException
Creates a property (indexed, and not stored) for the specified reader.

Throws:
SearchEngineException

createProperty

Property createProperty(String name,
                        byte[] value,
                        Property.Store store)
                        throws SearchEngineException
Creates a binary property.

Throws:
SearchEngineException

begin

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

Throws:
SearchEngineException

begin

void begin(CompassTransaction.TransactionIsolation transactionIsolation)
           throws SearchEngineException
Begins the search engine transaction using the given 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

isReadOnly

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


flush

void flush()
           throws SearchEngineException
Flushed the current transaction. Currently only works with batch insert transaction.

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

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