Class CmsSearchManager
- All Implemented Interfaces:
I_CmsEventListener,I_CmsScheduledJob
- Since:
- 6.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEnumeration class for force unlock types.protected classHandles offline index generation.protected classThe offline indexer thread runs periodically and indexes all resources added by the event handler.protected classAn offline index worker Thread runs each time for every offline index update action.protected classHelper class for batching resources arising from multiple independent 'instant publish' operations for indexing. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default value used for generating search result excerpts (1024 chars).static final floatThe default value used for keeping the extraction results in the cache (672 hours = 4 weeks).static final intThe default maximal wait time for re-indexing after editing a content.static final intDefault for the maximum number of modifications before a commit in the search index is triggered (500).static final intThe default update frequency for offline indexes (15000 msec = 15 sec).static final intThe default timeout value used for generating a document for the search index (60000 msec = 1 min).static final StringScheduler parameter: Update only a specified list of indexes.static final StringScheduler parameter: Write the output of the update to the logfile.protected static final org.apache.commons.logging.LogThe log object for this class.static final StringPrefix for Lucene default analyzers package (org.apache.lucene.analysis.).protected CmsObjectThe administrator OpenCms user context to access OpenCms VFS resources.protected List<I_CmsSearchIndex> The list of indexes that are configured for offline index mode.The thread used of offline indexing.Fields inherited from interface org.opencms.main.I_CmsEventListener
EVENT_BEFORE_PUBLISH_PROJECT, EVENT_CLEAR_CACHES, EVENT_CLEAR_OFFLINE_CACHES, EVENT_CLEAR_ONLINE_CACHES, EVENT_CLEAR_PRINCIPAL_CACHES, EVENT_FLEX_CACHE_CLEAR, EVENT_FLEX_PURGE_JSP_REPOSITORY, EVENT_FULLSTATIC_EXPORT, EVENT_GROUP_MODIFIED, EVENT_LOGIN_USER, EVENT_OU_MODIFIED, EVENT_PROJECT_MODIFIED, EVENT_PROPERTY_DEFINITION_CREATED, EVENT_PROPERTY_DEFINITION_MODIFIED, EVENT_PROPERTY_MODIFIED, EVENT_PUBLISH_PROJECT, EVENT_REBUILD_SEARCHINDEXES, EVENT_REINDEX_OFFLINE, EVENT_REINDEX_ONLINE, EVENT_RESOURCE_AND_PROPERTIES_MODIFIED, EVENT_RESOURCE_COPIED, EVENT_RESOURCE_CREATED, EVENT_RESOURCE_DELETED, EVENT_RESOURCE_MODIFIED, EVENT_RESOURCE_MOVED, EVENT_RESOURCES_AND_PROPERTIES_MODIFIED, EVENT_RESOURCES_MODIFIED, EVENT_SITEMAP_CHANGED, EVENT_UPDATE_EXPORTS, EVENT_USER_MODIFIED, KEY_CHANGE, KEY_DBCONTEXT, KEY_GROUP_ID, KEY_GROUP_NAME, KEY_INDEX_NAMES, KEY_INSTANT_PUBLISH, KEY_IS_ONLINE, KEY_OU_ID, KEY_OU_NAME, KEY_PROJECTID, KEY_PUBLISHID, KEY_PUBLISHLIST, KEY_REINDEX_RELATED, KEY_REPORT, KEY_RESOURCE, KEY_RESOURCES, KEY_SKIPINDEX, KEY_USER_ACTION, KEY_USER_CHANGES, KEY_USER_ID, KEY_USER_NAME, LISTENERS_FOR_ALL_EVENTS, VALUE_CREATE_SIBLING, VALUE_GROUP_MODIFIED_ACTION_CREATE, VALUE_GROUP_MODIFIED_ACTION_DELETE, VALUE_GROUP_MODIFIED_ACTION_WRITE, VALUE_OU_MODIFIED_ACTION_CREATE, VALUE_OU_MODIFIED_ACTION_DELETE, VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP, VALUE_USER_MODIFIED_ACTION_CREATE_USER, VALUE_USER_MODIFIED_ACTION_DELETE_USER, VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP, VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD, VALUE_USER_MODIFIED_ACTION_SET_OU, VALUE_USER_MODIFIED_ACTION_WRITE_USER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<CmsPublishedResource> addAdditionallyAffectedResources(CmsObject adminCms, List<CmsPublishedResource> updateResources) Collects the resources whose indexed document depends on one of the updated resources.voidaddAnalyzer(CmsSearchAnalyzer analyzer) Adds an analyzer.voidaddDocumentTypeConfig(CmsSearchDocumentType documentType) Adds a document type.voidaddFieldConfiguration(I_CmsSearchFieldConfiguration fieldConfiguration) Adds a search field configuration to the search manager.protected Collection<CmsPublishedResource> addIndexContentRelatedResources(CmsObject adminCms, Collection<CmsPublishedResource> updateResources, Collection<CmsPublishedResource> updateResourcesToCheck) Collects the resources whose indexed document depends on one of the updated resources.voidaddSearchIndex(I_CmsSearchIndex searchIndex) Adds a search index to the configuration.voidaddSearchIndexSource(CmsSearchIndexSource searchIndexSource) Adds a search index source configuration.protected voidCleans up the extraction result cache.voidImplements the event listener of this class.protected Collection<CmsPublishedResource> findRelatedContainerPages(CmsObject adminCms, Collection<CmsPublishedResource> updateResources, Collection<CmsPublishedResource> updateResourcesToCheck) Collects the related containerpages to the resources that have been published.Returns all Solr index.static org.apache.lucene.analysis.AnalyzergetAnalyzer(String className) Returns an analyzer for the given class name.org.apache.lucene.analysis.AnalyzergetAnalyzer(Locale locale) Returns an analyzer for the given language.Returns an unmodifiable view of the map that contains theCmsSearchAnalyzerlist.getCmsSearchAnalyzer(Locale locale) Returns the search analyzer for the given locale.Returns the name of the directory below WEB-INF/ where the search indexes are stored.Returns the configured Solr home directorynullif not set.getDocumentFactoryForName(String docTypeName) Returns the document factory configured under the provided name.getDocumentTypeConfig(String name) Returns a document type config.Returns an unmodifiable view (read-only) of the DocumentTypeConfigs Map.getDocumentTypeKeys(String resourceType, String mimeType) Returns the document type keys used to specify the correct document factory.getDocumentTypeKeys(CmsResource resource) Returns the document type keys used to specify the correct document factory.getDocumentTypeMapForTypeNames(List<String> documentTypeNames) Returns the map from document type keys to document factories with all entries for the provided document type names.Returns the set of names of all configured document types.floatReturns the maximum age a text extraction result is kept in the cache (in hours).getFieldConfiguration(String name) Returns the search field configuration with the given name.Returns the unmodifieable List of configuredI_CmsSearchFieldConfigurationentries.Returns the Lucene search field configurations only.Returns the Solr search field configurations only.Returns the force unlock mode during indexing.Returns the highlighter.Returns the Lucene search index configured with the given name.intReturns the seconds to wait for an index lock during an update operation.Returns the names of all configured indexes.getIndexSolr(String indexName) Returns the Solr index configured with the given name.static final CmsSolrIndexgetIndexSolr(CmsObject cms, Map<String, String[]> params) Returns the Solr index configured with the parameters name.getIndexSource(String sourceName) Returns a search index source for a specified source name.intReturns the max.longReturns the maximal time to wait for re-indexing after a content is edited (in milliseconds).intReturns the maximum number of modifications before a commit in the search index is triggered.protected CmsProjectReturns the a offline project used for offline indexing.longReturns the update frequency of the offline indexer in milliseconds.Returns an unmodifiable list of all configuredinstances.I_CmsSearchIndexReturns an unmodifiable list of all configuredinstances.I_CmsSearchIndexReturns an unmodifiable list of all configuredinstances.I_CmsSearchIndexReturns an unmodifiable view (read-only) of the SearchIndexSources Map.Return singleton instance of the OpenCms spellchecker.Returns the Solr configuration.protected CmsIndexingThreadManagerReturns a new thread manager for the indexing threads.longReturns the timeout to abandon threads indexing a resource.protected voidInitializes the available Cms resource types to be indexed.voidinitialize(CmsObject cms) Initializes the search manager.voidCallsI_CmsSearchFieldConfiguration.init()for all registered field configurations.voidInitializes all configured document types, index sources and search indexes.protected voidInitializes the index sources.voidInitialize the offline index handler, require after an offline index has been added.protected voidInitializes the configured search indexes.voidinitSpellcheckIndex(CmsObject adminCms) Initializes the spell check index.static booleanisLuceneIndex(String indexName) Returnstrueif the index for the given name is a Lucene index,falseotherwise.booleanReturns if the offline indexing is paused.Updates the indexes from as a scheduled job.Pauses the offline indexing and returns a pause request id that has to be used for resuming offline indexing again.voidrebuildAllIndexes(I_CmsReport report) Rebuilds (if required creates) all configured indexes.voidrebuildIndex(String indexName, I_CmsReport report) Rebuilds (if required creates) the index with the given name.voidrebuildIndexes(List<String> indexNames, I_CmsReport report) Rebuilds (if required creates) the List of indexes with the given name.voidregisterSolrIndex(CmsSolrIndex index) Registers a new Solr core for the given index.booleanremoveSearchFieldConfiguration(I_CmsSearchFieldConfiguration fieldConfiguration) Removes this field configuration from the OpenCms configuration (if it is not used any more).booleanremoveSearchFieldConfigurationField(I_CmsSearchFieldConfiguration fieldConfiguration, CmsSearchField field) Removes a search field from the field configuration.booleanremoveSearchFieldMapping(CmsLuceneField field, CmsSearchFieldMapping mapping) Removes a search field mapping from the given field.voidremoveSearchIndex(I_CmsSearchIndex searchIndex) Removes a search index from the configuration.voidremoveSearchIndexes(List<String> indexNames) Removes all indexes included in the given list (which must contain the name of an index to remove).booleanremoveSearchIndexSource(CmsSearchIndexSource indexsource) Removes this indexsource from the OpenCms configuration (if it is not used any more).voidresumeOfflineIndexing(CmsUUID pauseId) Resumes offline indexing if it was paused and no pause for another pauseId is still present.voidsetDirectory(String value) Sets the name of the directory below WEB-INF/ where the search indexes are stored.voidsetExtractionCacheMaxAge(float extractionCacheMaxAge) Sets the maximum age a text extraction result is kept in the cache (in hours).voidsetExtractionCacheMaxAge(String extractionCacheMaxAge) Sets the maximum age a text extraction result is kept in the cache (in hours) as a String.voidsetForceunlock(String value) Sets the unlock mode during indexing.voidsetHighlighter(String highlighter) Sets the highlighter.voidsetIndexLockMaxWaitSeconds(int value) Sets the seconds to wait for an index lock during an update operation.voidsetMaxExcerptLength(int maxExcerptLength) Sets the max.voidsetMaxExcerptLength(String maxExcerptLength) Sets the max.voidsetMaxIndexWaitTime(long maxIndexWaitTime) Sets the maximal wait time for offline index updates after edit operations.voidsetMaxIndexWaitTime(String maxIndexWaitTime) Sets the maximal wait time for offline index updates after edit operations.voidsetMaxModificationsBeforeCommit(int maxModificationsBeforeCommit) Sets the maximum number of modifications before a commit in the search index is triggered.voidSets the maximum number of modifications before a commit in the search index is triggered as a string.voidsetOfflineUpdateFrequency(long offlineUpdateFrequency) Sets the update frequency of the offline indexer in milliseconds.voidsetOfflineUpdateFrequency(String offlineUpdateFrequency) Sets the update frequency of the offline indexer in milliseconds.voidSets the Solr configuration.voidsetTimeout(long value) Sets the timeout to abandon threads indexing a resource.voidsetTimeout(String value) Sets the timeout to abandon threads indexing a resource as a String.protected booleanChecks, if the index should be rebuilt/updated at all by the search manager.voidshutDown()Shuts down the search manager.protected voidupdateAllIndexes(CmsObject adminCms, List<CmsPublishedResource> updateResources, I_CmsReport report) Incrementally updates all indexes that have their rebuild mode set to"auto".protected voidupdateAllIndexes(CmsObject adminCms, CmsUUID publishHistoryId, I_CmsReport report) Incrementally updates all indexes that have their rebuild mode set to"auto"after resources have been published.protected voidupdateIndex(I_CmsSearchIndex index, I_CmsReport report, List<CmsPublishedResource> resourcesToIndex) Updates (if required creates) the index with the given name.protected voidupdateIndexCompletely(CmsObject cms, I_CmsSearchIndex index, I_CmsReport report) The method updates all OpenCms documents that are indexed.protected voidupdateIndexIncremental(CmsObject cms, I_CmsSearchIndex index, I_CmsReport report, List<CmsPublishedResource> resourcesToIndex) Incrementally updates the given index.protected voidupdateIndexOffline(I_CmsReport report, List<CmsPublishedResource> resourcesToIndex) Updates the offline search indexes for the given list of resources.voidUpdates all offline indexes.voidupdateOfflineIndexes(long waitTime) Updates all offline indexes.
-
Field Details
-
DEFAULT_EXCERPT_LENGTH
The default value used for generating search result excerpts (1024 chars).- See Also:
-
DEFAULT_EXTRACTION_CACHE_MAX_AGE
The default value used for keeping the extraction results in the cache (672 hours = 4 weeks).- See Also:
-
DEFAULT_MAX_MODIFICATIONS_BEFORE_COMMIT
Default for the maximum number of modifications before a commit in the search index is triggered (500).- See Also:
-
DEFAULT_OFFLINE_UPDATE_FREQNENCY
The default update frequency for offline indexes (15000 msec = 15 sec).- See Also:
-
DEFAULT_MAX_INDEX_WAITTIME
The default maximal wait time for re-indexing after editing a content.- See Also:
-
DEFAULT_TIMEOUT
The default timeout value used for generating a document for the search index (60000 msec = 1 min).- See Also:
-
JOB_PARAM_INDEXLIST
Scheduler parameter: Update only a specified list of indexes.- See Also:
-
JOB_PARAM_WRITELOG
Scheduler parameter: Write the output of the update to the logfile.- See Also:
-
LUCENE_ANALYZER
Prefix for Lucene default analyzers package (org.apache.lucene.analysis.).- See Also:
-
LOG
The log object for this class. -
m_adminCms
The administrator OpenCms user context to access OpenCms VFS resources. -
m_offlineIndexes
The list of indexes that are configured for offline index mode. -
m_offlineIndexThread
The thread used of offline indexing.
-
-
Constructor Details
-
CmsSearchManager
public CmsSearchManager()Default constructor when called as cron job.
-
-
Method Details
-
getAnalyzer
Returns an analyzer for the given class name.- Parameters:
className- the class name of the analyzer- Returns:
- the appropriate lucene analyzer
- Throws:
Exception- if something goes wrong
-
getIndexSolr
Returns the Solr index configured with the parameters name. The parameters must contain a key/value pair with an existing Solr index, otherwisenullis returned.- Parameters:
cms- the current contextparams- the parameter map- Returns:
- the best matching Solr index
-
isLuceneIndex
Returnstrueif the index for the given name is a Lucene index,falseotherwise.- Parameters:
indexName- the name of the index to check- Returns:
trueif the index for the given name is a Lucene index
-
addAnalyzer
Adds an analyzer.- Parameters:
analyzer- an analyzer
-
addDocumentTypeConfig
Adds a document type.- Parameters:
documentType- a document type
-
addFieldConfiguration
Adds a search field configuration to the search manager.- Parameters:
fieldConfiguration- the search field configuration to add
-
addSearchIndex
Adds a search index to the configuration.- Parameters:
searchIndex- the search index to add
-
addSearchIndexSource
Adds a search index source configuration.- Parameters:
searchIndexSource- a search index source configuration
-
cmsEvent
Implements the event listener of this class.- Specified by:
cmsEventin interfaceI_CmsEventListener- Parameters:
event- CmsEvent that has occurred- See Also:
-
getAllSolrIndexes
Returns all Solr index.- Returns:
- all Solr indexes
-
getAnalyzer
Returns an analyzer for the given language.The analyzer is selected according to the analyzer configuration.
- Parameters:
locale- the locale to get the analyzer for- Returns:
- the appropriate lucene analyzer
- Throws:
CmsSearchException- if something goes wrong
-
getAnalyzers
Returns an unmodifiable view of the map that contains theCmsSearchAnalyzerlist.The keys in the map are
Localeobjects, and the values areCmsSearchAnalyzerobjects.- Returns:
- an unmodifiable view of the Analyzers Map
-
getCmsSearchAnalyzer
Returns the search analyzer for the given locale.- Parameters:
locale- the locale to get the analyzer for- Returns:
- the search analyzer for the given locale
-
getDirectory
Returns the name of the directory below WEB-INF/ where the search indexes are stored.- Returns:
- the name of the directory below WEB-INF/ where the search indexes are stored
-
getDirectorySolr
Returns the configured Solr home directorynullif not set.- Returns:
- the Solr home directory
-
getDocumentFactoryForName
Returns the document factory configured under the provided name.- Parameters:
docTypeName- the name of the document type.- Returns:
- the factory for the provided name.
-
getDocumentTypeConfig
Returns a document type config.- Parameters:
name- the name of the document type config- Returns:
- the document type config.
-
getDocumentTypeConfigs
Returns an unmodifiable view (read-only) of the DocumentTypeConfigs Map.- Returns:
- an unmodifiable view (read-only) of the DocumentTypeConfigs Map
-
getDocumentTypeKeys
Returns the document type keys used to specify the correct document factory.- Parameters:
resource- the resource to generate the list of document type keys for.- Returns:
- the document type keys.
- See Also:
-
getDocumentTypeKeys
Returns the document type keys used to specify the correct document factory. One resource typically has more than one key. The document factories are matched in the provided order and the first matching factory is used. The keys for type name "typename" and mimetype "mimetype" would be a subset of:typename_mimetypetypename- if
typenameis a sub-type ofcontainerpagecontainerpage_mimetypecontainerpage
- if
typenameis a sub-type ofxmlcontentxmlcontent_mimetypexmlcontent
__unconfigured___mimetype__unconfigured____all___mimetype__all__
-
Note that all keys except the "__all__"-keys are only added as long as globally
there is no matching factory for the key.
This in particular means that a factory matching "typename" will never be used
if you have a factory for "typename__mimetype" - even if this is not configured
for the used index source. Eventually, the content will not be indexed in such cases.
- Parameters:
resourceType- the resource type to generate the list of document type keys for.mimeType- the mime type to generate the list of document type keys for.- Returns:
- the document type keys.
-
getDocumentTypeMapForTypeNames
public Map<String,I_CmsDocumentFactory> getDocumentTypeMapForTypeNames(List<String> documentTypeNames) Returns the map from document type keys to document factories with all entries for the provided document type names.- Parameters:
documentTypeNames- list of document type names to generate the map for.- Returns:
- the map from document type keys to document factories.
-
getExtractionCacheMaxAge
Returns the maximum age a text extraction result is kept in the cache (in hours).- Returns:
- the maximum age a text extraction result is kept in the cache (in hours)
-
getFieldConfiguration
Returns the search field configuration with the given name.In case no configuration is available with the given name,
nullis returned.- Parameters:
name- the name to get the search field configuration for- Returns:
- the search field configuration with the given name
-
getFieldConfigurations
Returns the unmodifieable List of configuredI_CmsSearchFieldConfigurationentries.- Returns:
- the unmodifieable List of configured
I_CmsSearchFieldConfigurationentries
-
getFieldConfigurationsLucene
Returns the Lucene search field configurations only.- Returns:
- the Lucene search field configurations
-
getFieldConfigurationsSolr
Returns the Solr search field configurations only.- Returns:
- the Solr search field configurations
-
getForceunlock
Returns the force unlock mode during indexing.- Returns:
- the force unlock mode during indexing
-
getHighlighter
Returns the highlighter.- Returns:
- the highlighter
-
getIndex
Returns the Lucene search index configured with the given name.The index must exist, otherwise
nullis returned.- Parameters:
indexName- then name of the requested search index- Returns:
- the Lucene search index configured with the given name
-
getIndexLockMaxWaitSeconds
Returns the seconds to wait for an index lock during an update operation.- Returns:
- the seconds to wait for an index lock during an update operation
-
getIndexNames
Returns the names of all configured indexes.- Returns:
- list of names
-
getIndexSolr
Returns the Solr index configured with the given name.The index must exist, otherwise
nullis returned.- Parameters:
indexName- then name of the requested Solr index- Returns:
- the Solr index configured with the given name
-
getIndexSource
Returns a search index source for a specified source name.- Parameters:
sourceName- the name of the index source- Returns:
- a search index source
-
getMaxExcerptLength
Returns the max. excerpt length.- Returns:
- the max excerpt length
-
getMaxIndexWaitTime
Returns the maximal time to wait for re-indexing after a content is edited (in milliseconds).- Returns:
- the maximal time to wait for re-indexing after a content is edited (in milliseconds)
-
getMaxModificationsBeforeCommit
Returns the maximum number of modifications before a commit in the search index is triggered.- Returns:
- the maximum number of modifications before a commit in the search index is triggered
-
getOfflineUpdateFrequency
Returns the update frequency of the offline indexer in milliseconds.- Returns:
- the update frequency of the offline indexer in milliseconds
-
getSearchIndexes
Returns an unmodifiable list of all configuredinstances.I_CmsSearchIndex- Returns:
- an unmodifiable list of all configured
instancesI_CmsSearchIndex
-
getSearchIndexesAll
Returns an unmodifiable list of all configuredinstances.I_CmsSearchIndex- Returns:
- an unmodifiable list of all configured
instancesI_CmsSearchIndex
-
getSearchIndexesSolr
Returns an unmodifiable list of all configuredinstances.I_CmsSearchIndex- Returns:
- an unmodifiable list of all configured
instancesI_CmsSearchIndex
-
getSearchIndexSources
Returns an unmodifiable view (read-only) of the SearchIndexSources Map.- Returns:
- an unmodifiable view (read-only) of the SearchIndexSources Map
-
getSolrDictionary
Return singleton instance of the OpenCms spellchecker.- Returns:
- instance of CmsSolrSpellchecker.
-
getSolrServerConfiguration
Returns the Solr configuration.- Returns:
- the Solr configuration
-
getTimeout
Returns the timeout to abandon threads indexing a resource.- Returns:
- the timeout to abandon threads indexing a resource
-
initialize
Initializes the search manager.- Parameters:
cms- the cms object- Throws:
CmsRoleViolationException- in case the given opencms object does not havepermissionsCmsRole.WORKPLACE_MANAGER
-
initializeFieldConfigurations
CallsI_CmsSearchFieldConfiguration.init()for all registered field configurations. -
initializeIndexes
Initializes all configured document types, index sources and search indexes.This method needs to be called if after a change in the index configuration has been made.
-
initOfflineIndexes
Initialize the offline index handler, require after an offline index has been added. -
initSpellcheckIndex
Initializes the spell check index.- Parameters:
adminCms- the ROOT_ADMIN cms context
-
isOfflineIndexingPaused
Returns if the offline indexing is paused.- Returns:
trueif the offline indexing is paused
-
launch
Updates the indexes from as a scheduled job.- Specified by:
launchin interfaceI_CmsScheduledJob- Parameters:
cms- the OpenCms user context to use when reading resources from the VFSparameters- the parameters for the scheduled job- Returns:
- the String to write in the scheduler log
- Throws:
Exception- if something goes wrong- See Also:
-
pauseOfflineIndexing
Pauses the offline indexing and returns a pause request id that has to be used for resuming offline indexing again.May take some time, because the indexes are updated first.
- Returns:
- the pause request id. The id has to be given to the
resumeOfflineIndexing(CmsUUID)method to resume offline indexing.
-
rebuildAllIndexes
Rebuilds (if required creates) all configured indexes.- Parameters:
report- the report object to write messages (ornull)- Throws:
CmsException- if something goes wrong
-
rebuildIndex
Rebuilds (if required creates) the index with the given name.- Parameters:
indexName- the name of the index to rebuildreport- the report object to write messages (ornull)- Throws:
CmsException- if something goes wrong
-
rebuildIndexes
Rebuilds (if required creates) the List of indexes with the given name.- Parameters:
indexNames- the names (String) of the index to rebuildreport- the report object to write messages (ornull)- Throws:
CmsException- if something goes wrong
-
registerSolrIndex
Registers a new Solr core for the given index.- Parameters:
index- the index to register a new Solr core for- Throws:
CmsConfigurationException- if no Solr server is configured
-
removeSearchFieldConfiguration
public boolean removeSearchFieldConfiguration(I_CmsSearchFieldConfiguration fieldConfiguration) throws CmsIllegalStateException Removes this field configuration from the OpenCms configuration (if it is not used any more).- Parameters:
fieldConfiguration- the field configuration to remove from the configuration- Returns:
- true if remove was successful, false if preconditions for removal are ok but the given field configuration was unknown to the manager.
- Throws:
CmsIllegalStateException- if the given field configuration is still used by at least one.I_CmsSearchIndex
-
removeSearchFieldConfigurationField
public boolean removeSearchFieldConfigurationField(I_CmsSearchFieldConfiguration fieldConfiguration, CmsSearchField field) Removes a search field from the field configuration.- Parameters:
fieldConfiguration- the field configurationfield- field to remove from the field configuration- Returns:
- true if remove was successful, false if preconditions for removal are ok but the given field was unknown.
-
removeSearchFieldMapping
public boolean removeSearchFieldMapping(CmsLuceneField field, CmsSearchFieldMapping mapping) throws CmsIllegalStateException Removes a search field mapping from the given field.- Parameters:
field- the fieldmapping- mapping to remove from the field- Returns:
- true if remove was successful, false if preconditions for removal are ok but the given mapping was unknown.
- Throws:
CmsIllegalStateException- if the given mapping is the last mapping inside the given field.
-
removeSearchIndex
Removes a search index from the configuration.- Parameters:
searchIndex- the search index to remove
-
removeSearchIndexes
Removes all indexes included in the given list (which must contain the name of an index to remove).- Parameters:
indexNames- the names of the index to remove
-
removeSearchIndexSource
public boolean removeSearchIndexSource(CmsSearchIndexSource indexsource) throws CmsIllegalStateException Removes this indexsource from the OpenCms configuration (if it is not used any more).- Parameters:
indexsource- the indexsource to remove from the configuration- Returns:
- true if remove was successful, false if preconditions for removal are ok but the given searchindex was unknown to the manager.
- Throws:
CmsIllegalStateException- if the given indexsource is still used by at least one.I_CmsSearchIndex
-
resumeOfflineIndexing
Resumes offline indexing if it was paused and no pause for another pauseId is still present.- Parameters:
pauseId- the id of the pause request, which now allows for resuming.
-
setDirectory
Sets the name of the directory below WEB-INF/ where the search indexes are stored.- Parameters:
value- the name of the directory below WEB-INF/ where the search indexes are stored
-
setExtractionCacheMaxAge
Sets the maximum age a text extraction result is kept in the cache (in hours).- Parameters:
extractionCacheMaxAge- the maximum age for a text extraction result to set
-
setExtractionCacheMaxAge
Sets the maximum age a text extraction result is kept in the cache (in hours) as a String.- Parameters:
extractionCacheMaxAge- the maximum age for a text extraction result to set
-
setForceunlock
Sets the unlock mode during indexing.- Parameters:
value- the value
-
setHighlighter
Sets the highlighter.A highlighter is a class implementing org.opencms.search.documents.I_TermHighlighter.
- Parameters:
highlighter- the package/class name of the highlighter
-
setIndexLockMaxWaitSeconds
Sets the seconds to wait for an index lock during an update operation.- Parameters:
value- the seconds to wait for an index lock during an update operation
-
setMaxExcerptLength
Sets the max. excerpt length.- Parameters:
maxExcerptLength- the max. excerpt length to set
-
setMaxExcerptLength
Sets the max. excerpt length as a String.- Parameters:
maxExcerptLength- the max. excerpt length to set
-
setMaxIndexWaitTime
Sets the maximal wait time for offline index updates after edit operations.- Parameters:
maxIndexWaitTime- the maximal wait time to set in milliseconds
-
setMaxIndexWaitTime
Sets the maximal wait time for offline index updates after edit operations.- Parameters:
maxIndexWaitTime- the maximal wait time to set in milliseconds
-
setMaxModificationsBeforeCommit
Sets the maximum number of modifications before a commit in the search index is triggered.- Parameters:
maxModificationsBeforeCommit- the maximum number of modifications to set
-
setMaxModificationsBeforeCommit
Sets the maximum number of modifications before a commit in the search index is triggered as a string.- Parameters:
value- the maximum number of modifications to set
-
setOfflineUpdateFrequency
Sets the update frequency of the offline indexer in milliseconds.- Parameters:
offlineUpdateFrequency- the update frequency in milliseconds to set
-
setOfflineUpdateFrequency
Sets the update frequency of the offline indexer in milliseconds.- Parameters:
offlineUpdateFrequency- the update frequency in milliseconds to set
-
setSolrServerConfiguration
Sets the Solr configuration.- Parameters:
config- the Solr configuration
-
setTimeout
Sets the timeout to abandon threads indexing a resource.- Parameters:
value- the timeout in milliseconds
-
setTimeout
Sets the timeout to abandon threads indexing a resource as a String.- Parameters:
value- the timeout in milliseconds
-
shutDown
Shuts down the search manager.This will cause all search indices to be shut down.
-
updateOfflineIndexes
Updates all offline indexes.Can be used to force an index update when it's not convenient to wait until the offline update interval has eclipsed.
Since the offline indexes still need some time to update the new resources, the method waits for at most the configurable
maxIndexWaitTimeto ensure that updating is finished.- See Also:
-
updateOfflineIndexes
Updates all offline indexes.Can be used to force an index update when it's not convenient to wait until the offline update interval has eclipsed.
Since the offline index will still need some time to update the new resources even if it runs directly, a wait time of 2500 or so should be given in order to make sure the index finished updating.
- Parameters:
waitTime- milliseconds to wait after the offline update index was notified of the changes
-
addAdditionallyAffectedResources
protected List<CmsPublishedResource> addAdditionallyAffectedResources(CmsObject adminCms, List<CmsPublishedResource> updateResources) Collects the resources whose indexed document depends on one of the updated resources.We take transitive dependencies into account and handle cyclic dependencies correctly as well.
- Parameters:
adminCms- an OpenCms user context with Admin permissionsupdateResources- the resources to be re-indexed- Returns:
- the updated list of resource to re-index
-
addIndexContentRelatedResources
protected Collection<CmsPublishedResource> addIndexContentRelatedResources(CmsObject adminCms, Collection<CmsPublishedResource> updateResources, Collection<CmsPublishedResource> updateResourcesToCheck) Collects the resources whose indexed document depends on one of the updated resources.- Parameters:
adminCms- an OpenCms user context with Admin permissionsupdateResources- the resources to be re-indexedupdateResourcesToCheck- the resources to check additionally affected resources for, subset of updateResources- Returns:
- the list of resources that need to be additionally re-index
-
cleanExtractionCache
Cleans up the extraction result cache. -
findRelatedContainerPages
protected Collection<CmsPublishedResource> findRelatedContainerPages(CmsObject adminCms, Collection<CmsPublishedResource> updateResources, Collection<CmsPublishedResource> updateResourcesToCheck) Collects the related containerpages to the resources that have been published.- Parameters:
adminCms- an OpenCms user context with Admin permissionsupdateResources- the resources to be re-indexedupdateResourcesToCheck- the resources to check additionally affected resources for, subset of updateResources- Returns:
- the list of resources that need to be additionally re-index
-
getDocumentTypes
Returns the set of names of all configured document types.- Returns:
- the set of names of all configured document types
-
getOfflineIndexProject
Returns the a offline project used for offline indexing.- Returns:
- the offline project if available
-
getThreadManager
Returns a new thread manager for the indexing threads.- Returns:
- a new thread manager for the indexing threads
-
initAvailableDocumentTypes
Initializes the available Cms resource types to be indexed.A map stores document factories keyed by a string representing a colon separated list of Cms resource types and/or mimetypes.
The keys of this map are used to trigger a document factory to convert a Cms resource into a Lucene index document.
A document factory is a class implementing the interface
I_CmsDocumentFactory. -
initIndexSources
Initializes the index sources. -
initSearchIndexes
Initializes the configured search indexes.This initializes also the list of Cms resources types to be indexed by an index source.
-
shouldUpdateAtAll
Checks, if the index should be rebuilt/updated at all by the search manager.- Parameters:
index- the index to check.- Returns:
- a flag, indicating if the index should be rebuilt/updated at all.
-
updateAllIndexes
Incrementally updates all indexes that have their rebuild mode set to"auto"after resources have been published.- Parameters:
adminCms- an OpenCms user context with Admin permissionspublishHistoryId- the history ID of the published projectreport- the report to write the output to
-
updateAllIndexes
protected void updateAllIndexes(CmsObject adminCms, List<CmsPublishedResource> updateResources, I_CmsReport report) Incrementally updates all indexes that have their rebuild mode set to"auto".- Parameters:
adminCms- an OpenCms user context with Admin permissionsupdateResources- the resources to updatereport- the report to write the output to
-
updateIndex
protected void updateIndex(I_CmsSearchIndex index, I_CmsReport report, List<CmsPublishedResource> resourcesToIndex) throws CmsException Updates (if required creates) the index with the given name.If the optional List of
instances is provided, the index will be incrementally updated for these resources only. If this List isCmsPublishedResourcenullor empty, the index will be fully rebuild.- Parameters:
index- the index to update or rebuildreport- the report to write output messages toresourcesToIndex- an (optional) list ofobjects to update in the indexCmsPublishedResource- Throws:
CmsException- if something goes wrong
-
updateIndexCompletely
protected void updateIndexCompletely(CmsObject cms, I_CmsSearchIndex index, I_CmsReport report) throws CmsIndexException The method updates all OpenCms documents that are indexed.- Parameters:
cms- the OpenCms user context to use for accessing the VFSindex- the index to updatereport- the report to write output messages to- Throws:
CmsIndexException- thrown if indexing fails for some reason
-
updateIndexIncremental
protected void updateIndexIncremental(CmsObject cms, I_CmsSearchIndex index, I_CmsReport report, List<CmsPublishedResource> resourcesToIndex) throws CmsException Incrementally updates the given index.- Parameters:
cms- the OpenCms user context to use for accessing the VFSindex- the index to updatereport- the report to write output messages toresourcesToIndex- a list ofobjects to update in the indexCmsPublishedResource- Throws:
CmsException- if something goes wrong
-
updateIndexOffline
Updates the offline search indexes for the given list of resources.- Parameters:
report- the report to write the index information toresourcesToIndex- the list ofCmsPublishedResourceobjects to index
-