org.alfresco.repo.search.impl.lucene
Class AbstractLuceneBase

java.lang.Object
  extended by org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
Direct Known Subclasses:
AbstractLuceneIndexerImpl, ADMLuceneSearcherImpl

public abstract class AbstractLuceneBase
extends java.lang.Object

Common support for abstracting the lucene indexer from its configuration and management requirements.

This class defines where the indexes are stored. This should be via a configurable Bean property in Spring.

The default file structure is

  1. "base"/"protocol"/"name"/ for the main index
  2. "base"/"protocol"/"name"/deltas/"id" for transactional updates
  3. "base"/"protocol"/"name"/undo/"id" undo information

The IndexWriter and IndexReader for a given index are toggled (one should be used for delete and the other for write). These are reused/closed/initialised as required.

The index deltas are buffered to memory and persisted in the file system as required.


Field Summary
protected  java.lang.String deltaId
          The identifier for the delta
protected  org.alfresco.service.cmr.repository.StoreRef store
          The identifier for the store
 
Constructor Summary
AbstractLuceneBase()
           
 
Method Summary
protected  void closeDeltaReader()
          Close the on file reader for the delta if it is open
protected  void closeDeltaWriter()
          Close the on disk delta writer
 void deleteIndex()
           
 java.lang.Object doReadOnly(IndexInfo.LockWork lockWork)
          Execute actions against a read only index (all write ops will block)
 java.lang.String getDeltaId()
          Get the ID for the delat we are working with.
protected  org.apache.lucene.index.IndexReader getDeltaReader()
          Get a reader for the on file portion of the delta
protected  org.apache.lucene.index.IndexWriter getDeltaWriter()
          Get the on file writer for the delta
 org.alfresco.service.cmr.dictionary.DictionaryService getDictionaryService()
          Get the dictionary service.
 LuceneConfig getLuceneConfig()
          Get the lucene configuration options.
protected  org.apache.lucene.index.IndexReader getReader()
           
protected  org.apache.lucene.search.IndexSearcher getSearcher()
          Get a searcher for the main index TODO: Split out support for the main index.
protected  ClosingIndexSearcher getSearcher(LuceneIndexer luceneIndexer)
           
protected  TransactionStatus getStatus()
           
protected  void initialise(org.alfresco.service.cmr.repository.StoreRef store, java.lang.String deltaId)
          Initialise the configuration elements of the lucene store indexers and searchers.
protected  void saveDelta()
          Save the in memory delta to the disk, make sure there is nothing held in memory
 void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
          Set the dictionary service
protected  void setInfo(long docs, java.util.Set deletions, java.util.Set containerDeletions, boolean deleteNodesOnly)
           
 void setLuceneConfig(LuceneConfig config)
          Set the lucene configuration options
protected  void setStatus(TransactionStatus status)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected org.alfresco.service.cmr.repository.StoreRef store
The identifier for the store


deltaId

protected java.lang.String deltaId
The identifier for the delta

Constructor Detail

AbstractLuceneBase

public AbstractLuceneBase()
Method Detail

initialise

protected void initialise(org.alfresco.service.cmr.repository.StoreRef store,
                          java.lang.String deltaId)
                   throws LuceneIndexException
Initialise the configuration elements of the lucene store indexers and searchers.

Parameters:
store -
deltaId -
Throws:
java.io.IOException
LuceneIndexException

getSearcher

protected org.apache.lucene.search.IndexSearcher getSearcher()
                                                      throws LuceneIndexException
Get a searcher for the main index TODO: Split out support for the main index. We really only need this if we want to search over the changing index before it is committed

Returns:
- the searcher
Throws:
java.io.IOException
LuceneIndexException

getSearcher

protected ClosingIndexSearcher getSearcher(LuceneIndexer luceneIndexer)
                                    throws LuceneIndexException
Throws:
LuceneIndexException

getDeltaReader

protected org.apache.lucene.index.IndexReader getDeltaReader()
                                                      throws LuceneIndexException,
                                                             java.io.IOException
Get a reader for the on file portion of the delta

Returns:
- the index reader
Throws:
java.io.IOException
java.io.IOException
LuceneIndexException

closeDeltaReader

protected void closeDeltaReader()
                         throws LuceneIndexException,
                                java.io.IOException
Close the on file reader for the delta if it is open

Throws:
java.io.IOException
java.io.IOException
LuceneIndexException

getDeltaWriter

protected org.apache.lucene.index.IndexWriter getDeltaWriter()
                                                      throws LuceneIndexException,
                                                             java.io.IOException
Get the on file writer for the delta

Returns:
- the writer for the delta
Throws:
java.io.IOException
java.io.IOException
LuceneIndexException

closeDeltaWriter

protected void closeDeltaWriter()
                         throws LuceneIndexException,
                                java.io.IOException
Close the on disk delta writer

Throws:
java.io.IOException
java.io.IOException
LuceneIndexException

saveDelta

protected void saveDelta()
                  throws LuceneIndexException,
                         java.io.IOException
Save the in memory delta to the disk, make sure there is nothing held in memory

Throws:
java.io.IOException
java.io.IOException
LuceneIndexException

setInfo

protected void setInfo(long docs,
                       java.util.Set deletions,
                       java.util.Set containerDeletions,
                       boolean deleteNodesOnly)
                throws java.io.IOException
Throws:
java.io.IOException

setStatus

protected void setStatus(TransactionStatus status)
                  throws java.io.IOException
Throws:
java.io.IOException

getStatus

protected TransactionStatus getStatus()

getReader

protected org.apache.lucene.index.IndexReader getReader()
                                                 throws LuceneIndexException,
                                                        java.io.IOException
Throws:
LuceneIndexException
java.io.IOException

setDictionaryService

public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
Set the dictionary service

Parameters:
dictionaryService -

getDictionaryService

public org.alfresco.service.cmr.dictionary.DictionaryService getDictionaryService()
Get the dictionary service.

Returns:
- the service

setLuceneConfig

public void setLuceneConfig(LuceneConfig config)
Set the lucene configuration options

Parameters:
config -

getLuceneConfig

public LuceneConfig getLuceneConfig()
Get the lucene configuration options.

Returns:
- the config options object.

getDeltaId

public java.lang.String getDeltaId()
Get the ID for the delat we are working with.

Returns:
- the id

doReadOnly

public java.lang.Object doReadOnly(IndexInfo.LockWork lockWork)
Execute actions against a read only index (all write ops will block)

Parameters:
lockWork -
Returns:
- the result returned by the action.

deleteIndex

public void deleteIndex()


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.