|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.search.CmsSearchManager
Implements the general management and configuration of the search and indexing facilities in OpenCms.
Field Summary | |
static java.lang.String |
JOB_PARAM_INDEXLIST
Scheduler parameter: Update only a specified list of indexes. |
static java.lang.String |
JOB_PARAM_WRITELOG
Scheduler parameter: Write the output of the update to the logfile. |
Constructor Summary | |
CmsSearchManager()
Default constructer when called as cron job. |
Method Summary | |
void |
addAnalyzer(CmsSearchAnalyzer analyzer)
Adds an analyzer. |
void |
addDocumentTypeConfig(CmsSearchDocumentType documentType)
Adds a document type. |
void |
addSearchIndex(CmsSearchIndex searchIndex)
Adds a search index to the configuration. |
void |
addSearchIndexSource(CmsSearchIndexSource searchIndexSource)
Adds a search index source configuration. |
protected boolean |
checkIndexLock(CmsSearchIndex index,
I_CmsReport report)
Checks is a given index is locked, if so waits for a numer of seconds and checks again, until either the index is unlocked or a limit of seconds set by
is reached. |
void |
cmsEvent(CmsEvent event)
Implements the event listener of this class. |
protected org.apache.lucene.analysis.Analyzer |
getAnalyzer(java.lang.String locale)
Returns an analyzer for the given language. |
java.util.Map |
getAnalyzers()
Returns an unmodifiable view (read-only) of the Analyzers Map. |
CmsSearchAnalyzer |
getCmsSearchAnalyzer(java.lang.String locale)
Returns the CmsSearchAnalyzer Object. |
java.lang.String |
getDirectory()
Returns the name of the directory below WEB-INF/ where the search indexes are stored. |
protected I_CmsDocumentFactory |
getDocumentFactory(A_CmsIndexResource resource)
Returns a lucene document factory for given resource. |
CmsSearchDocumentType |
getDocumentTypeConfig(java.lang.String name)
Returns a document type config. |
java.util.Map |
getDocumentTypeConfigs()
Returns an unmodifiable view (read-only) of the DocumentTypeConfigs Map. |
protected java.util.List |
getDocumentTypes()
Returns the set of names of all configured documenttypes. |
I_CmsTermHighlighter |
getHighlighter()
Returns the highlighter. |
CmsSearchIndex |
getIndex(java.lang.String indexName)
Returns the index belonging to the passed name. |
int |
getIndexLockMaxWaitSeconds()
Returns the seconds to wait for an index lock during an update operation. |
java.util.List |
getIndexNames()
Returns the names of all configured indexes. |
CmsSearchIndexSource |
getIndexSource(java.lang.String sourceName)
Returns a search index source for a specified source name. |
int |
getMaxExcerptLength()
Returns the max. excerpt length. |
protected java.util.Map |
getResultCache()
Returns the common cache for buffering search results. |
java.lang.String |
getResultCacheSize()
Returns the result cache size. |
java.util.List |
getSearchIndexes()
Returns an unmodifiable list of all configured instances. |
java.util.Map |
getSearchIndexSources()
Returns an unmodifiable view (read-only) of the SearchIndexSources Map. |
java.lang.String |
getTimeout()
Returns the timeout to abandon threads indexing a resource. |
protected void |
initAvailableDocumentTypes()
Initializes the available Cms resource types to be indexed. |
void |
initialize(CmsObject cms)
Initializes the search manager. |
void |
initializeIndexes()
Initializes all configured document types and search indexes. |
protected void |
initSearchIndexes()
Initializes the configured search indexes. |
java.lang.String |
launch(CmsObject cms,
java.util.Map parameters)
Updates the indexes from as a scheduled job. |
void |
rebuildAllIndexes(I_CmsReport report)
Rebuilds (if required creates) all configured indexes. |
void |
rebuildAllIndexes(I_CmsReport report,
boolean wait)
Rebuilds (if required creates) all configured indexes. |
void |
rebuildIndex(java.lang.String indexName,
I_CmsReport report)
Rebuilds (if required creates) the index with the given name. |
void |
rebuildIndexes(java.util.List indexNames,
I_CmsReport report)
Rebuilds (if required creates) the List of indexes with the given name. |
void |
removeSearchIndex(CmsSearchIndex searchIndex)
Removes a search index from the configuration. |
void |
removeSearchIndexes(java.util.List indexNames)
Removes all indexes included in the given list (which must contain the name of an index to remove). |
boolean |
removeSearchIndexSource(CmsSearchIndexSource indexsource)
Removes this indexsource from the OpenCms configuration (if it is not used any more). |
void |
setDirectory(java.lang.String value)
Sets the name of the directory below WEB-INF/ where the search indexes are stored. |
void |
setHighlighter(java.lang.String highlighter)
Sets the highlighter. |
void |
setIndexLockMaxWaitSeconds(int value)
Sets the seconds to wait for an index lock during an update operation. |
void |
setMaxExcerptLength(java.lang.String maxExcerptLength)
Sets the max. excerpt length. |
void |
setResultCacheSize(java.lang.String value)
Sets the result cache size. |
void |
setTimeout(java.lang.String value)
Sets the timeout to abandon threads indexing a resource. |
protected void |
updateAllIndexes(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 void |
updateIndex(CmsSearchIndex index,
I_CmsReport report,
boolean wait,
java.util.List resourcesToIndex,
java.util.Map documentCache)
Updates (if required creates) the index with the given name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String JOB_PARAM_INDEXLIST
public static final java.lang.String JOB_PARAM_WRITELOG
Constructor Detail |
public CmsSearchManager()
Method Detail |
public void addAnalyzer(CmsSearchAnalyzer analyzer)
analyzer
- an analyzerpublic void addDocumentTypeConfig(CmsSearchDocumentType documentType)
documentType
- a document typepublic void addSearchIndex(CmsSearchIndex searchIndex)
searchIndex
- the search index to addpublic void addSearchIndexSource(CmsSearchIndexSource searchIndexSource)
searchIndexSource
- a search index source configurationpublic void cmsEvent(CmsEvent event)
cmsEvent
in interface I_CmsEventListener
event
- CmsEvent that has occurredI_CmsEventListener.cmsEvent(org.opencms.main.CmsEvent)
public java.util.Map getAnalyzers()
public CmsSearchAnalyzer getCmsSearchAnalyzer(java.lang.String locale)
locale
- unique locale key to specify the CmsSearchAnalyzer in HashMap
public java.lang.String getDirectory()
public CmsSearchDocumentType getDocumentTypeConfig(java.lang.String name)
name
- the name of the document type config
public java.util.Map getDocumentTypeConfigs()
public I_CmsTermHighlighter getHighlighter()
public CmsSearchIndex getIndex(java.lang.String indexName)
The index must exist already.
indexName
- then name of the index
public int getIndexLockMaxWaitSeconds()
public java.util.List getIndexNames()
public CmsSearchIndexSource getIndexSource(java.lang.String sourceName)
sourceName
- the name of the index source
public int getMaxExcerptLength()
public java.lang.String getResultCacheSize()
public java.util.List getSearchIndexes()
CmsSearchIndex
instances.
CmsSearchIndex
instancespublic java.util.Map getSearchIndexSources()
public java.lang.String getTimeout()
public void initialize(CmsObject cms) throws CmsRoleViolationException
cms
- the cms object
CmsRoleViolationException
- in case the given opencms object does not have CmsRole.SEARCH_MANAGER
permissionspublic void initializeIndexes()
This methods needs to be called if after a change in the index configuration has been made.
public final java.lang.String launch(CmsObject cms, java.util.Map parameters) throws java.lang.Exception
launch
in interface I_CmsScheduledJob
cms
- the OpenCms user context to use when reading resources from the VFSparameters
- the parameters for the scheduled job
java.lang.Exception
- if something goes wrongI_CmsScheduledJob.launch(org.opencms.file.CmsObject, java.util.Map)
public void rebuildAllIndexes(I_CmsReport report) throws CmsException
report
- the report object to write messages (or null
)
CmsException
- if something goes wrongpublic void rebuildAllIndexes(I_CmsReport report, boolean wait) throws CmsException
report
- the report object to write messages (or null
)wait
- signals to wait until all the indexing threads are finished
CmsException
- if something goes wrongpublic void rebuildIndex(java.lang.String indexName, I_CmsReport report) throws CmsException
indexName
- the name of the index to rebuildreport
- the report object to write messages (or null
)
CmsException
- if something goes wrongpublic void rebuildIndexes(java.util.List indexNames, I_CmsReport report) throws CmsException
indexNames
- the names (String) of the index to rebuildreport
- the report object to write messages (or null
)
CmsException
- if something goes wrongpublic void removeSearchIndex(CmsSearchIndex searchIndex)
searchIndex
- the search index to removepublic void removeSearchIndexes(java.util.List indexNames)
indexNames
- the names of the index to removepublic boolean removeSearchIndexSource(CmsSearchIndexSource indexsource) throws CmsIllegalStateException
indexsource
- the indexsource to remove from the configuration
CmsIllegalStateException
- if the given indexsource is still used by at least one
CmsSearchIndex
.public void setDirectory(java.lang.String value)
value
- the name of the directory below WEB-INF/ where the search indexes are storedpublic void setHighlighter(java.lang.String highlighter)
A highlighter is a class implementing org.opencms.search.documents.I_TermHighlighter.
highlighter
- the package/class name of the highlighterpublic void setIndexLockMaxWaitSeconds(int value)
value
- the seconds to wait for an index lock during an update operationpublic void setMaxExcerptLength(java.lang.String maxExcerptLength)
maxExcerptLength
- the max. excerpt length to setpublic void setResultCacheSize(java.lang.String value)
value
- the result cache sizepublic void setTimeout(java.lang.String value)
value
- the timeout in millisecondsprotected boolean checkIndexLock(CmsSearchIndex index, I_CmsReport report)
setIndexLockMaxWaitSeconds(int)
is reached.
index
- the index to check the lock forreport
- the report to write error messages on
true
if the index is lockedprotected org.apache.lucene.analysis.Analyzer getAnalyzer(java.lang.String locale) throws CmsIndexException
The analyzer is selected according to the analyzer configuration.
locale
- a language id, i.e. de, en, it
CmsIndexException
- if something goes wrongprotected I_CmsDocumentFactory getDocumentFactory(A_CmsIndexResource resource)
The type of the document factory is selected by the type of the resource and the mimetype of the resource content according to the documenttype configuration.
resource
- a cms resource
protected java.util.List getDocumentTypes()
protected java.util.Map getResultCache()
protected void initAvailableDocumentTypes()
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
.
protected void initSearchIndexes()
This initializes also the list of Cms resources types to be indexed by an index source.
protected void updateAllIndexes(CmsObject adminCms, CmsUUID publishHistoryId, I_CmsReport report)
"auto"
after resources have been published.
adminCms
- an OpenCms user context with Admin permissionspublishHistoryId
- the history ID of the published projectreport
- the report to write the output toprotected void updateIndex(CmsSearchIndex index, I_CmsReport report, boolean wait, java.util.List resourcesToIndex, java.util.Map documentCache) throws CmsException
If the optional List of
instances is provided, the index will be
incrementally updated for these resources only. If this List is CmsPublishedResource
null
or empty,
the index will be fully rebuild.
index
- the index to update or rebuildreport
- the report to write output messages towait
- signals to wait until all the indexing threads are finishedresourcesToIndex
- an (optional) list of CmsPublishedResource
objects to update in the indexdocumentCache
- a cache for the created search documents, to avoid multiple text extraction
CmsException
- if something goes wrong
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |