Class AbstractLuceneBase
- java.lang.Object
-
- org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
-
- Direct Known Subclasses:
AbstractLuceneIndexerImpl
public abstract class AbstractLuceneBase extends java.lang.ObjectCommon 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
- "base"/"protocol"/"name"/ for the main index
- "base"/"protocol"/"name"/deltas/"id" for transactional updates
- "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.
- Author:
- Andy Hind
-
-
Constructor Summary
Constructors Constructor Description AbstractLuceneBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseDeltaReader()Close the on file reader for the delta if it is openprotected voidcloseDeltaWriter()Close the on disk delta writervoiddeleteIndex()<R> RdoReadOnly(IndexInfo.LockWork<R> lockWork)Execute actions against a read only index (all write ops will block)java.lang.StringgetDeltaId()Get the ID for the delat we are working with.protected org.apache.lucene.index.IndexReadergetDeltaReader()Get a reader for the on file portion of the deltaprotected org.apache.lucene.index.IndexWritergetDeltaWriter()Get the on file writer for the deltaorg.alfresco.service.cmr.dictionary.DictionaryServicegetDictionaryService()Get the dictionary service.LuceneConfiggetLuceneConfig()Get the lucene configuration options.protected org.apache.lucene.index.IndexReadergetReader()protected org.apache.lucene.search.IndexSearchergetSearcher()Get a searcher for the main index TODO: Split out support for the main index.protected ClosingIndexSearchergetSearcher(LuceneIndexer luceneIndexer)protected TransactionStatusgetStatus()protected voidinitialise(org.alfresco.service.cmr.repository.StoreRef store, java.lang.String deltaId)Initialise the configuration elements of the lucene store indexers and searchers.protected voidsaveDelta()Save the in memory delta to the disk, make sure there is nothing held in memoryvoidsetDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)Set the dictionary serviceprotected voidsetInfo(long docs, java.util.Set<java.lang.String> deletions, java.util.Set<java.lang.String> containerDeletions, boolean deleteNodesOnly)voidsetLuceneConfig(LuceneConfig config)Set the lucene configuration optionsprotected voidsetStatus(TransactionStatus status)
-
-
-
Method Detail
-
initialise
protected void initialise(org.alfresco.service.cmr.repository.StoreRef store, java.lang.String deltaId) throws LuceneIndexExceptionInitialise the configuration elements of the lucene store indexers and searchers.- Parameters:
store- StoreRefdeltaId- String- Throws:
LuceneIndexException
-
getSearcher
protected org.apache.lucene.search.IndexSearcher getSearcher() throws LuceneIndexExceptionGet 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:
LuceneIndexException
-
getSearcher
protected ClosingIndexSearcher getSearcher(LuceneIndexer luceneIndexer) throws LuceneIndexException
- Throws:
LuceneIndexException
-
getDeltaReader
protected org.apache.lucene.index.IndexReader getDeltaReader() throws LuceneIndexException, java.io.IOExceptionGet a reader for the on file portion of the delta- Returns:
- - the index reader
- Throws:
java.io.IOExceptionjava.io.IOExceptionLuceneIndexException
-
closeDeltaReader
protected void closeDeltaReader() throws LuceneIndexException, java.io.IOExceptionClose the on file reader for the delta if it is open- Throws:
java.io.IOExceptionjava.io.IOExceptionLuceneIndexException
-
getDeltaWriter
protected org.apache.lucene.index.IndexWriter getDeltaWriter() throws LuceneIndexException, java.io.IOExceptionGet the on file writer for the delta- Returns:
- - the writer for the delta
- Throws:
java.io.IOExceptionjava.io.IOExceptionLuceneIndexException
-
closeDeltaWriter
protected void closeDeltaWriter() throws LuceneIndexException, java.io.IOExceptionClose the on disk delta writer- Throws:
java.io.IOExceptionjava.io.IOExceptionLuceneIndexException
-
saveDelta
protected void saveDelta() throws LuceneIndexException, java.io.IOExceptionSave the in memory delta to the disk, make sure there is nothing held in memory- Throws:
java.io.IOExceptionjava.io.IOExceptionLuceneIndexException
-
setInfo
protected void setInfo(long docs, java.util.Set<java.lang.String> deletions, java.util.Set<java.lang.String> 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:
LuceneIndexExceptionjava.io.IOException
-
setDictionaryService
public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
Set the dictionary service- Parameters:
dictionaryService- 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- LuceneConfig
-
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 <R> R doReadOnly(IndexInfo.LockWork<R> lockWork)
Execute actions against a read only index (all write ops will block)- Returns:
- - the result returned by the action.
-
deleteIndex
public void deleteIndex()
-
-