Class AbstractSearchIndexingProcessor

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

    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 Detail

      • 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:
        Constant Field Values
      • 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 Detail

      • AbstractSearchIndexingProcessor

        public AbstractSearchIndexingProcessor()
    • Method Detail

      • 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
      • doCreateIndexIfMissing

        protected abstract void doCreateIndexIfMissing​(Target target)
      • 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
      • doCommit

        protected abstract void doCommit​(String indexId)
      • isDescriptor

        protected boolean isDescriptor​(String path)
      • isComponent

        protected boolean isComponent​(String path)
      • 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)