Package org.imixs.workflow.engine.lucene
Class LuceneIndexService
- java.lang.Object
-
- org.imixs.workflow.engine.lucene.LuceneIndexService
-
public class LuceneIndexService extends Object
This session ejb provides functionality to maintain a local Lucene index.- Version:
- 1.0
- Author:
- rsoika
-
-
Field Summary
Fields Modifier and Type Field Description static StringANONYMOUSstatic StringDEFAULT_ANALYZERstatic StringDEFAULT_INDEX_DIRECTORYstatic intEVENTLOG_ENTRY_FLUSH_COUNTprotected jakarta.enterprise.event.Event<IndexEvent>indexEventsstatic StringTAXONOMY_INDEXFIELD_PRAFIX
-
Constructor Summary
Constructors Constructor Description LuceneIndexService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddItemValues(org.apache.lucene.document.Document doc, ItemCollection workitem, String _itemName, boolean analyzeValue, boolean store)adds a field value into a Lucene document.protected org.apache.lucene.document.DocumentcreateDocument(ItemCollection document)This method creates a lucene document based on a ItemCollection.org.apache.lucene.store.DirectorycreateIndexDirectory()Creates a Lucene FSDirectory Instance.protected org.apache.lucene.index.IndexWritercreateIndexWriter()This method creates a new instance of a lucene IndexWriter.org.apache.lucene.store.DirectorycreateTaxonomyDirectory()Creates a Lucene FSDirectory Instance.protected org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWritercreateTaxonomyWriter()Create taxonomyWriter in a separate directory from the main index with the paefix '_taxÄ'booleanflushEventLog(int junkSize)Flush the EventLog cache.protected booleanflushEventLogByCount(int count)This method flushes a given count of eventLogEntries.org.apache.lucene.facet.FacetsConfiggetFacetsConfig()This method builds a facetcConfig for the taxonomy index writer where each category item is marked as a multiValued field.StringgetLuceneAnalyzerClass()StringgetLuceneIndexDir()voidindexDocuments(Collection<ItemCollection> documents)This method adds a collection of documents to the Lucene index.voidrebuildIndex(org.apache.lucene.store.Directory indexDir)This method forces an update of the full text index.voidsetLuceneAnalyzerClass(String luceneAnalyzerClass)voidsetLuceneIndexDir(String luceneIndexDir)
-
-
-
Field Detail
-
EVENTLOG_ENTRY_FLUSH_COUNT
public static final int EVENTLOG_ENTRY_FLUSH_COUNT
- See Also:
- Constant Field Values
-
ANONYMOUS
public static final String ANONYMOUS
- See Also:
- Constant Field Values
-
DEFAULT_ANALYZER
public static final String DEFAULT_ANALYZER
- See Also:
- Constant Field Values
-
DEFAULT_INDEX_DIRECTORY
public static final String DEFAULT_INDEX_DIRECTORY
- See Also:
- Constant Field Values
-
TAXONOMY_INDEXFIELD_PRAFIX
public static final String TAXONOMY_INDEXFIELD_PRAFIX
- See Also:
- Constant Field Values
-
indexEvents
@Inject protected jakarta.enterprise.event.Event<IndexEvent> indexEvents
-
-
Method Detail
-
getLuceneIndexDir
public String getLuceneIndexDir()
-
setLuceneIndexDir
public void setLuceneIndexDir(String luceneIndexDir)
-
getLuceneAnalyzerClass
public String getLuceneAnalyzerClass()
-
setLuceneAnalyzerClass
public void setLuceneAnalyzerClass(String luceneAnalyzerClass)
-
flushEventLog
public boolean flushEventLog(int junkSize)
Flush the EventLog cache. This method is called by the LuceneSerachService only.The method flushes the cache in smaller blocks of the given junkSize. to avoid a heap size problem. The default flush size is 16. The eventLog cache is tracked by the flag 'dirtyIndex'.
issue #439 - The method returns false if the event log contains more entries as defined by the given JunkSize. In this case the caller should recall the method which runs always in a new transaction. The goal of this mechanism is to reduce the event log even in cases the outer transaction breaks.
- Returns:
- true if the the complete event log was flushed. If false the method must be recalled.
- See Also:
LuceneSearchService
-
rebuildIndex
public void rebuildIndex(org.apache.lucene.store.Directory indexDir) throws IOExceptionThis method forces an update of the full text index. The method also creates the index directory if it does not yet exist.- Throws:
IOException
-
indexDocuments
public void indexDocuments(Collection<ItemCollection> documents)
This method adds a collection of documents to the Lucene index. The documents are added immediately to the index. Calling this method within a running transaction leads to a uncommitted reads in the index. For transaction control, it is recommended to use instead the the method updateDocumetns() which takes care of uncommitted reads.This method is used by the JobHandlerRebuildIndex only.
- Parameters:
documents- of ItemCollections to be indexed- Throws:
IndexException
-
flushEventLogByCount
protected boolean flushEventLogByCount(int count)
This method flushes a given count of eventLogEntries. The method return true if no more eventLogEntries exist.- Parameters:
count- the max size of a eventLog engries to remove.- Returns:
- true if the cache was totally flushed.
-
getFacetsConfig
public org.apache.lucene.facet.FacetsConfig getFacetsConfig()
This method builds a facetcConfig for the taxonomy index writer where each category item is marked as a multiValued field.- Returns:
-
createDocument
protected org.apache.lucene.document.Document createDocument(ItemCollection document)
This method creates a lucene document based on a ItemCollection. The Method creates for each field specified in the FieldList a separate index field for the lucene document. The property 'AnalyzeIndexFields' defines if a indexfield value should by analyzed by the Lucene Analyzer (default=false)- Parameters:
document- - the Imixs document to be indexed- Returns:
- - a lucene document instance
-
addItemValues
protected void addItemValues(org.apache.lucene.document.Document doc, ItemCollection workitem, String _itemName, boolean analyzeValue, boolean store)adds a field value into a Lucene document. The parameter store specifies if the value will become part of the Lucene document which is optional.- Parameters:
doc- an existing lucene documentworkitem- the workitem containg the valuesitemName- the Fieldname inside the workitemanalyzeValue- indicates if the value should be parsed by the analyzerstore- indicates if the value will become part of the Lucene document
-
createIndexWriter
protected org.apache.lucene.index.IndexWriter createIndexWriter() throws IOExceptionThis method creates a new instance of a lucene IndexWriter. The location of the lucene index in the filesystem is read from the imixs.properties- Returns:
- Throws:
IOException
-
createTaxonomyWriter
protected org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter createTaxonomyWriter() throws IOExceptionCreate taxonomyWriter in a separate directory from the main index with the paefix '_taxÄ'- Returns:
- Throws:
IOException
-
createIndexDirectory
public org.apache.lucene.store.Directory createIndexDirectory() throws IOExceptionCreates a Lucene FSDirectory Instance. The method uses the property LockFactory to set a custom LockFactory. For example: org.apache.lucene.store.SimpleFSLockFactory- Returns:
- Throws:
IOException
-
createTaxonomyDirectory
public org.apache.lucene.store.Directory createTaxonomyDirectory() throws IOExceptionCreates a Lucene FSDirectory Instance. The method uses the property LockFactory to set a custom LockFactory.The taxonomy directory is identified by the LuceneIndexDir with the praefix '_tax'
- Returns:
- Throws:
IOException
-
-