Package org.imixs.workflow.engine.lucene
Class LuceneIndexService
java.lang.Object
org.imixs.workflow.engine.lucene.LuceneIndexService
This session ejb provides functionality to maintain a local Lucene index.
- Version:
- 1.0
- Author:
- rsoika
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final int
protected jakarta.enterprise.event.Event<IndexEvent>
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addItemValues
(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.Document
createDocument
(ItemCollection document) This method creates a lucene document based on a ItemCollection.org.apache.lucene.store.Directory
Creates a Lucene FSDirectory Instance.protected org.apache.lucene.index.IndexWriter
This method creates a new instance of a lucene IndexWriter.org.apache.lucene.store.Directory
Creates a Lucene FSDirectory Instance.protected org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter
Create taxonomyWriter in a separate directory from the main index with the paefix '_taxÄ'boolean
flushEventLog
(int junkSize) Flush the EventLog cache.protected boolean
flushEventLogByCount
(int count) This method flushes a given count of eventLogEntries.org.apache.lucene.facet.FacetsConfig
This method builds a facetcConfig for the taxonomy index writer where each category item is marked as a multiValued field.void
indexDocuments
(Collection<ItemCollection> documents) This method adds a collection of documents to the Lucene index.void
rebuildIndex
(org.apache.lucene.store.Directory indexDir) This method forces an update of the full text index.void
setLuceneAnalyzerClass
(String luceneAnalyzerClass) void
setLuceneIndexDir
(String luceneIndexDir)
-
Field Details
-
EVENTLOG_ENTRY_FLUSH_COUNT
public static final int EVENTLOG_ENTRY_FLUSH_COUNT- See Also:
-
ANONYMOUS
- See Also:
-
DEFAULT_ANALYZER
- See Also:
-
DEFAULT_INDEX_DIRECTORY
- See Also:
-
TAXONOMY_INDEXFIELD_PRAFIX
- See Also:
-
indexEvents
-
-
Constructor Details
-
LuceneIndexService
public LuceneIndexService()
-
-
Method Details
-
getLuceneIndexDir
-
setLuceneIndexDir
-
getLuceneAnalyzerClass
-
setLuceneAnalyzerClass
-
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:
-
rebuildIndex
This 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
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
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
This 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
Creates 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
Creates 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
-