SMILA (incubation) API documentation

org.eclipse.smila.lucene.internal
Class LuceneServiceImpl

java.lang.Object
  extended by org.eclipse.smila.lucene.internal.LuceneServiceImpl
All Implemented Interfaces:
LuceneIndexService, LuceneSearchService, LuceneService

public class LuceneServiceImpl
extends java.lang.Object
implements LuceneService, LuceneSearchService, LuceneIndexService

Abstract base class for services dealing with Lucene.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.smila.lucene.LuceneIndexService
LuceneIndexService.ExecutionMode
 
Field Summary
 
Fields inherited from interface org.eclipse.smila.lucene.LuceneSearchService
DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, MAPPINGS_ATTACHMENTS, MAPPINGS_ATTRIBUTES, RANKING_OPERATOR, RANKING_TOLERANCE, SEARCH_ANNOTATION_QUERY_ATTRIBUTE, SEARCH_ANNOTATION_TEMPLATE_SELECTOR_NAME
 
Fields inherited from interface org.eclipse.smila.lucene.LuceneIndexService
PROPERTY_FORCE_UNLOCK_INDEX, PROPERTY_TEMPORARY_INDEX_DIR
 
Fields inherited from interface org.eclipse.smila.lucene.LuceneService
BUNDLE_NAME, CONFIG_FILE_MAPPINGS, ID_FIELD
 
Constructor Summary
LuceneServiceImpl()
           
 
Method Summary
protected  void activate(ComponentContext context)
          DS activate method.
 void addRecord(Blackboard blackboard, java.lang.String id, java.lang.String indexName, boolean allowDoublets)
          Add a record to the Lucene index.
 void createIndex(java.lang.String indexName)
          Creates the index.
protected  void deactivate(ComponentContext context)
          DS deactivate method.
 void deleteIndex(java.lang.String indexName)
          Delete index.
 void deleteRecord(java.lang.String id, java.lang.String indexName)
          Delete a record from the Lucene index.
 void flushIndex(java.lang.String indexName)
          Flushes the index with the given name.
 java.util.Iterator<java.lang.String> getIndexNames()
          Returns the names of all available indexes.
protected  java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.Integer>>> getMappings()
          Returns the mappings.
 boolean isIndexExists(java.lang.String indexName)
          Checks if is index exists.
protected  void loadMappings()
          Loads the mappings.
 void removeWriteLock(java.lang.String indexName)
          Removes the write.lock of the Lucene index if any exists.
 void renameIndex(java.lang.String indexName, java.lang.String newIndexName)
          Rename index.
 void reorganizeIndex(java.lang.String indexName)
          Reorganize index.
 void search(Blackboard blackboard, java.lang.String requestId, QueryParameterAccessor parameters)
          Creates a query and executes the query on the lucene index.
protected  void unloadMappings()
          Unloads the mappings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneServiceImpl

public LuceneServiceImpl()
Method Detail

activate

protected void activate(ComponentContext context)
                 throws java.lang.Exception
DS activate method.

Parameters:
context - ComponentContext
Throws:
java.lang.Exception - if any error occurs

deactivate

protected void deactivate(ComponentContext context)
                   throws java.lang.Exception
DS deactivate method.

Parameters:
context - the ComponentContext
Throws:
java.lang.Exception - if any error occurs

search

public void search(Blackboard blackboard,
                   java.lang.String requestId,
                   QueryParameterAccessor parameters)
            throws BlackboardAccessException,
                   IndexException,
                   DataDictionaryException,
                   NodeTransformerException,
                   ProcessingException
Creates a query and executes the query on the lucene index.

Specified by:
search in interface LuceneSearchService
Parameters:
blackboard - the BlackBoardService
requestId - the record ID of the search request.
parameters - query parameters
Throws:
BlackboardAccessException - if any error occurs
IndexException - if any error occurs
DataDictionaryException - if any error occurs
NodeTransformerException - if any error occurs
ProcessingException - if parameter SEARCH_ANNOTATION_QUERY_ATTRIBUTE is not set for simple query or any other error occurs

addRecord

public void addRecord(Blackboard blackboard,
                      java.lang.String id,
                      java.lang.String indexName,
                      boolean allowDoublets)
               throws BlackboardAccessException,
                      IndexException,
                      java.io.IOException,
                      javax.xml.parsers.ParserConfigurationException
Add a record to the Lucene index.

Specified by:
addRecord in interface LuceneIndexService
Parameters:
blackboard - reference to the BlackboardService
id - Id of the record
indexName - name of the index
allowDoublets - boolean flag if doublets of documents are allowed in the index
Throws:
BlackboardAccessException - if any error occurs
IndexException - if any error occurs
java.io.IOException - if any error occurs
javax.xml.parsers.ParserConfigurationException - if any error occurs

deleteRecord

public void deleteRecord(java.lang.String id,
                         java.lang.String indexName)
                  throws IndexException
Delete a record from the Lucene index.

Specified by:
deleteRecord in interface LuceneIndexService
Parameters:
id - Id of the record
indexName - name of the index
Throws:
IndexException - if any error occurs

isIndexExists

public boolean isIndexExists(java.lang.String indexName)
                      throws IndexException
Checks if is index exists.

Specified by:
isIndexExists in interface LuceneIndexService
Parameters:
indexName - the index name
Returns:
true, if is index exists
Throws:
IndexException - the index exception

reorganizeIndex

public void reorganizeIndex(java.lang.String indexName)
                     throws IndexException
Reorganize index.

Specified by:
reorganizeIndex in interface LuceneIndexService
Parameters:
indexName - the index name
Throws:
IndexException - the index exception

createIndex

public void createIndex(java.lang.String indexName)
                 throws IndexException
Creates the index.

Specified by:
createIndex in interface LuceneIndexService
Parameters:
indexName - the index name
Throws:
IndexException - the index exception

deleteIndex

public void deleteIndex(java.lang.String indexName)
                 throws IndexException
Delete index.

Specified by:
deleteIndex in interface LuceneIndexService
Parameters:
indexName - the index name
Throws:
IndexException - the index exception

renameIndex

public void renameIndex(java.lang.String indexName,
                        java.lang.String newIndexName)
                 throws IndexException
Rename index.

Specified by:
renameIndex in interface LuceneIndexService
Parameters:
indexName - the index name
newIndexName - the new index name
Throws:
IndexException - the index exception

getIndexNames

public java.util.Iterator<java.lang.String> getIndexNames()
Returns the names of all available indexes.

Specified by:
getIndexNames in interface LuceneIndexService
Returns:
an iterator over index names

flushIndex

public void flushIndex(java.lang.String indexName)
                throws IndexException
Flushes the index with the given name.

Specified by:
flushIndex in interface LuceneIndexService
Parameters:
indexName - name of the index to flush
Throws:
IndexException - if any error occurs

removeWriteLock

public void removeWriteLock(java.lang.String indexName)
                     throws IndexException
Removes the write.lock of the Lucene index if any exists.

Specified by:
removeWriteLock in interface LuceneIndexService
Parameters:
indexName - the name of the index to remove the lock
Throws:
IndexException - if any error occurs

loadMappings

protected void loadMappings()
Loads the mappings.


unloadMappings

protected void unloadMappings()
Unloads the mappings.


getMappings

protected java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.Integer>>> getMappings()
Returns the mappings.

Returns:
the mappings.

SMILA (incubation) API documentation