Class AbstractSearchIndexingProcessor

All Implemented Interfaces:
DeploymentProcessor, InitializableByConfigBean, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
OpenSearchIndexingProcessor

public abstract class AbstractSearchIndexingProcessor extends AbstractMainDeploymentProcessor
Processor that indexes the files on the change set, using one or several BatchIndexer. After the files have been indexed it submits a commit. A processor instance can be configured with the following YAML properties:
  • ignoreIndexId: If the index ID should be ignored, in other words, if the index ID should always be null on update calls.
  • indexId: The specific index ID to use
  • reindexItemsOnComponentUpdates: Flag that indicates that if a component is updated, all other pages and components that include it should be updated too. This needs to be done when flattening is enabled, since the component needs to be re-included in pages/components. By default is true.
Author:
avasquez
  • Field Details

    • INDEX_ID_CONFIG_KEY

      protected static final String INDEX_ID_CONFIG_KEY
      See Also:
    • IGNORE_INDEX_ID_CONFIG_KEY

      protected static final String IGNORE_INDEX_ID_CONFIG_KEY
      See Also:
    • REINDEX_ITEMS_ON_COMPONENT_UPDATES

      protected static final String REINDEX_ITEMS_ON_COMPONENT_UPDATES
      See Also:
    • CREATE_INDEX_IF_MISSING_CONFIG_KEY

      protected static final String CREATE_INDEX_IF_MISSING_CONFIG_KEY
      See Also:
    • DEFAULT_DESCRIPTOR_PATH_PATTERN

      protected static final Pattern DEFAULT_DESCRIPTOR_PATH_PATTERN
    • DEFAULT_COMPONENT_PATH_PATTERN

      protected static final Pattern DEFAULT_COMPONENT_PATH_PATTERN
    • DEFAULT_ITEMS_THAT_INCLUDE_COMPONENT_QUERY_ROWS

      protected static final int DEFAULT_ITEMS_THAT_INCLUDE_COMPONENT_QUERY_ROWS
      See Also:
    • cacheTemplate

      protected org.craftercms.core.util.cache.CacheTemplate cacheTemplate
    • contextFactory

      protected org.springframework.beans.factory.ObjectFactory<org.craftercms.core.service.Context> contextFactory
    • contentStoreService

      protected org.craftercms.core.service.ContentStoreService contentStoreService
    • batchIndexers

      protected List<org.craftercms.search.batch.BatchIndexer> batchIndexers
    • xmlFlatteningEnabled

      protected boolean xmlFlatteningEnabled
    • descriptorPathPattern

      protected Pattern descriptorPathPattern
    • componentPathPattern

      protected Pattern componentPathPattern
    • itemsThatIncludeComponentQueryRows

      protected int itemsThatIncludeComponentQueryRows
    • indexIdFormat

      protected String indexIdFormat
    • indexId

      protected String indexId
    • reindexItemsOnComponentUpdates

      protected boolean reindexItemsOnComponentUpdates
    • createIndexIfMissing

      protected boolean createIndexIfMissing
  • Constructor Details

    • AbstractSearchIndexingProcessor

      public AbstractSearchIndexingProcessor()
  • Method Details

    • setCacheTemplate

      public void setCacheTemplate(org.craftercms.core.util.cache.CacheTemplate cacheTemplate)
    • setContextFactory

      public void setContextFactory(org.springframework.beans.factory.ObjectFactory<org.craftercms.core.service.Context> contextFactory)
      Sets the factory for the Context.
    • setContentStoreService

      public void setContentStoreService(org.craftercms.core.service.ContentStoreService contentStoreService)
      Sets the content store used to retrieve the files to index.
    • setBatchIndexer

      public void setBatchIndexer(org.craftercms.search.batch.BatchIndexer batchIndexer)
      Sets the single batch indexer used for indexing.
    • setBatchIndexers

      public void setBatchIndexers(List<org.craftercms.search.batch.BatchIndexer> batchIndexers)
      Sets the list of batch indexers used for indexing.
    • setXmlFlatteningEnabled

      public void setXmlFlatteningEnabled(boolean xmlFlatteningEnabled)
      Sets whether XML flattening is enabled. Only used in conjunction with reindexItemsOnComponentUpdates to see if pages/components should be re-indexed when components they include are updated.
    • setDescriptorPathRegex

      public void setDescriptorPathRegex(String descriptorPathRegex)
      Sets the regex used to match descriptor paths for detecting inheriting items that should be reindex.
    • setComponentPathRegex

      public void setComponentPathRegex(String componentPathRegex)
      Sets the regex used to match component paths (used when reindexItemsOnComponentUpdates is enabled).
    • setItemsThatIncludeComponentQueryRows

      public void setItemsThatIncludeComponentQueryRows(int itemsThatIncludeComponentQueryRows)
      Sets the rows to fetch for the search query used to find items that include components (used when reindexItemsOnComponentUpdates is enabled).
    • setIndexIdFormat

      public void setIndexIdFormat(String indexIdFormat)
      The format used for the index id
    • doInit

      protected void doInit(org.apache.commons.configuration2.Configuration config) throws org.craftercms.commons.config.ConfigurationException
      Description copied from class: AbstractDeploymentProcessor
      Allows extending classes perform any custom initialization
      Specified by:
      doInit in class AbstractDeploymentProcessor
      Parameters:
      config - the bean's configuration
      Throws:
      org.craftercms.commons.config.ConfigurationException - if there's configuration related exception
    • doDestroy

      protected void doDestroy() throws DeployerException
      Description copied from class: AbstractDeploymentProcessor
      Allows extending classes perform any custom cleanup
      Specified by:
      doDestroy in class AbstractDeploymentProcessor
      Throws:
      DeployerException - if an error occurs
    • supportsMode

      public boolean supportsMode(Deployment.Mode mode)
      Description copied from interface: DeploymentProcessor
      Indicates if the processor should be included in the given deployment mode
      Specified by:
      supportsMode in interface DeploymentProcessor
      Overrides:
      supportsMode in class AbstractDeploymentProcessor
      Parameters:
      mode - the deployment mode to check
      Returns:
      true if the processor should be included
    • doCreateIndexIfMissing

      protected abstract void doCreateIndexIfMissing()
    • getFilteredChangeSet

      protected ChangeSet getFilteredChangeSet(ChangeSet changeSet)
      Override to add pages/components that need to be updated because a component that they include was updated.
      Overrides:
      getFilteredChangeSet in class AbstractDeploymentProcessor
      Parameters:
      changeSet - original change set
      Returns:
      filtered change set
    • doMainProcess

      protected ChangeSet doMainProcess(Deployment deployment, ProcessorExecution execution, ChangeSet filteredChangeSet, ChangeSet originalChangeSet) throws DeployerException
      Description copied from class: AbstractMainDeploymentProcessor
      Performs the actual work of processing the files in the ChangeSet, it is also possible to return a new ChangeSet to be used for the following processors in the pipeline
      Specified by:
      doMainProcess in class AbstractMainDeploymentProcessor
      Parameters:
      deployment - the current deployment
      execution - the current execution
      filteredChangeSet - the filtered change set (as returned by AbstractDeploymentProcessor.getFilteredChangeSet(ChangeSet))
      originalChangeSet - the original change set (as returned by the previous processors in the pipeline)
      Returns:
      a new ChangeSet or null
      Throws:
      DeployerException - if there is any error processing the ChangeSet
    • doCommit

      protected abstract void doCommit(String indexId)
    • isDescriptor

      protected boolean isDescriptor(String path)
    • isComponent

      protected boolean isComponent(String path)
    • isBeingUpdatedOrDeleted

      protected boolean isBeingUpdatedOrDeleted(String path, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles)
    • getItemsThatInheritDescriptor

      protected abstract List<String> getItemsThatInheritDescriptor(String indexId, String descriptorPath)
    • addItemsThatInheritFromDescriptorToUpdatedFiles

      protected void addItemsThatInheritFromDescriptorToUpdatedFiles(String descriptorPath, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles)
    • getItemsThatIncludeComponent

      protected abstract List<String> getItemsThatIncludeComponent(String indexId, String componentPath)
    • addItemsThatIncludeComponentToUpdatedFiles

      protected void addItemsThatIncludeComponentToUpdatedFiles(String componentPath, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles)
    • addAffectedItemsToUpdatedFiles

      protected void addAffectedItemsToUpdatedFiles(String path, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles, BiFunction<String,String,List<String>> function)