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 Details

  • Constructor Details

    • LuceneIndexService

      public LuceneIndexService()
  • Method Details

    • 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:
    • rebuildIndex

      public void rebuildIndex(org.apache.lucene.store.Directory indexDir) throws IOException
      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

      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 document
      workitem - the workitem containg the values
      itemName - the Fieldname inside the workitem
      analyzeValue - indicates if the value should be parsed by the analyzer
      store - indicates if the value will become part of the Lucene document
    • createIndexWriter

      protected org.apache.lucene.index.IndexWriter createIndexWriter() throws IOException
      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 IOException
      Create 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 IOException
      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

      public org.apache.lucene.store.Directory createTaxonomyDirectory() throws IOException
      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