Class AbstractSearchIndexingProcessor
java.lang.Object
org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
org.craftercms.deployer.impl.processors.AbstractMainDeploymentProcessor
org.craftercms.deployer.impl.processors.AbstractSearchIndexingProcessor
- All Implemented Interfaces:
DeploymentProcessor
,InitializableByConfigBean
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
- Direct Known Subclasses:
OpenSearchIndexingProcessor
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 Summary
Modifier and TypeFieldDescriptionprotected List<org.craftercms.search.batch.BatchIndexer>
protected org.craftercms.core.util.cache.CacheTemplate
protected Pattern
protected org.craftercms.core.service.ContentStoreService
protected org.springframework.beans.factory.ObjectFactory<org.craftercms.core.service.Context>
protected static final String
protected boolean
protected static final Pattern
protected static final Pattern
protected static final int
protected Pattern
protected static final String
protected static final String
protected String
protected String
protected int
protected static final String
protected boolean
protected boolean
Fields inherited from class org.craftercms.deployer.impl.processors.AbstractMainDeploymentProcessor
FAIL_DEPLOYMENT_CONFIG_KEY, failDeploymentOnFailure
Fields inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
alwaysRun, env, excludeFiles, includeFiles, JUMPING_TO_PARAM_NAME, jumpTo, label, name, siteName, targetId
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAffectedItemsToUpdatedFiles
(String path, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles, BiFunction<String, String, List<String>> function) protected void
addItemsThatIncludeComponentToUpdatedFiles
(String componentPath, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles) protected void
addItemsThatInheritFromDescriptorToUpdatedFiles
(String descriptorPath, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles) protected abstract void
protected abstract void
protected void
Allows extending classes perform any custom cleanupprotected void
doInit
(org.apache.commons.configuration2.Configuration config) Allows extending classes perform any custom initializationprotected ChangeSet
doMainProcess
(Deployment deployment, ProcessorExecution execution, ChangeSet filteredChangeSet, ChangeSet originalChangeSet) protected ChangeSet
getFilteredChangeSet
(ChangeSet changeSet) Override to add pages/components that need to be updated because a component that they include was updated.getItemsThatIncludeComponent
(String indexId, String componentPath) getItemsThatInheritDescriptor
(String indexId, String descriptorPath) protected boolean
isBeingUpdatedOrDeleted
(String path, List<String> createdFiles, List<String> updatedFiles, List<String> deletedFiles) protected boolean
isComponent
(String path) protected boolean
isDescriptor
(String path) void
setBatchIndexer
(org.craftercms.search.batch.BatchIndexer batchIndexer) Sets the single batch indexer used for indexing.void
setBatchIndexers
(List<org.craftercms.search.batch.BatchIndexer> batchIndexers) Sets the list of batch indexers used for indexing.void
setCacheTemplate
(org.craftercms.core.util.cache.CacheTemplate cacheTemplate) void
setComponentPathRegex
(String componentPathRegex) Sets the regex used to match component paths (used whenreindexItemsOnComponentUpdates
is enabled).void
setContentStoreService
(org.craftercms.core.service.ContentStoreService contentStoreService) Sets the content store used to retrieve the files to index.void
setContextFactory
(org.springframework.beans.factory.ObjectFactory<org.craftercms.core.service.Context> contextFactory) Sets the factory for theContext
.void
setDescriptorPathRegex
(String descriptorPathRegex) Sets the regex used to match descriptor paths for detecting inheriting items that should be reindex.void
setIndexIdFormat
(String indexIdFormat) The format used for the index idvoid
setItemsThatIncludeComponentQueryRows
(int itemsThatIncludeComponentQueryRows) Sets the rows to fetch for the search query used to find items that include components (used whenreindexItemsOnComponentUpdates
is enabled).void
setXmlFlatteningEnabled
(boolean xmlFlatteningEnabled) Sets whether XML flattening is enabled.boolean
supportsMode
(Deployment.Mode mode) Indicates if the processor should be included in the given deployment modeMethods inherited from class org.craftercms.deployer.impl.processors.AbstractMainDeploymentProcessor
doExecute, failDeploymentOnProcessorFailure, init, shouldExecute
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
destroy, execute, isJumpToActive, isPostDeployment, setBeanName, setEnv, setSiteName, setTargetId, shouldIncludeFile, startJumpTo
-
Field Details
-
INDEX_ID_CONFIG_KEY
- See Also:
-
IGNORE_INDEX_ID_CONFIG_KEY
- See Also:
-
REINDEX_ITEMS_ON_COMPONENT_UPDATES
- See Also:
-
CREATE_INDEX_IF_MISSING_CONFIG_KEY
- See Also:
-
DEFAULT_DESCRIPTOR_PATH_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
-
xmlFlatteningEnabled
protected boolean xmlFlatteningEnabled -
descriptorPathPattern
-
componentPathPattern
-
itemsThatIncludeComponentQueryRows
protected int itemsThatIncludeComponentQueryRows -
indexIdFormat
-
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 theContext
. -
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
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 withreindexItemsOnComponentUpdates
to see if pages/components should be re-indexed when components they include are updated. -
setDescriptorPathRegex
Sets the regex used to match descriptor paths for detecting inheriting items that should be reindex. -
setComponentPathRegex
Sets the regex used to match component paths (used whenreindexItemsOnComponentUpdates
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 whenreindexItemsOnComponentUpdates
is enabled). -
setIndexIdFormat
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 classAbstractDeploymentProcessor
- Parameters:
config
- the bean's configuration- Throws:
org.craftercms.commons.config.ConfigurationException
- if there's configuration related exception
-
doDestroy
Description copied from class:AbstractDeploymentProcessor
Allows extending classes perform any custom cleanup- Specified by:
doDestroy
in classAbstractDeploymentProcessor
- Throws:
DeployerException
- if an error occurs
-
supportsMode
Description copied from interface:DeploymentProcessor
Indicates if the processor should be included in the given deployment mode- Specified by:
supportsMode
in interfaceDeploymentProcessor
- Overrides:
supportsMode
in classAbstractDeploymentProcessor
- Parameters:
mode
- the deployment mode to check- Returns:
- true if the processor should be included
-
doCreateIndexIfMissing
protected abstract void doCreateIndexIfMissing() -
getFilteredChangeSet
Override to add pages/components that need to be updated because a component that they include was updated.- Overrides:
getFilteredChangeSet
in classAbstractDeploymentProcessor
- 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 theChangeSet
, it is also possible to return a newChangeSet
to be used for the following processors in the pipeline- Specified by:
doMainProcess
in classAbstractMainDeploymentProcessor
- Parameters:
deployment
- the current deploymentexecution
- the current executionfilteredChangeSet
- the filtered change set (as returned byAbstractDeploymentProcessor.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 theChangeSet
-
doCommit
-
isDescriptor
-
isComponent
-
isBeingUpdatedOrDeleted
-
getItemsThatInheritDescriptor
-
addItemsThatInheritFromDescriptorToUpdatedFiles
-
getItemsThatIncludeComponent
-
addItemsThatIncludeComponentToUpdatedFiles
-
addAffectedItemsToUpdatedFiles
-