Package org.opencms.search
Interface I_CmsSearchIndex
- All Superinterfaces:
I_CmsConfigurationParameterHandler
,Serializable
- All Known Implementing Classes:
A_CmsSearchIndex
,CmsSearchIndex
,CmsSolrIndex
Interface for search indizes that should be handled by the
CmsSearchManager
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Automatic ("auto") index rebuild mode.static final String
Manual ("manual") index rebuild mode.static final String
Never ("never") index rebuild mode for indexes that should never be updated via OpenCms.static final String
Offline ("offline") index rebuild mode.Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSourceName
(String sourceName) Adds am index source to this search index.boolean
Checks is this index has been configured correctly.createEmptyDocument
(CmsResource resource) Creates an empty document that can be used by this search field configuration.boolean
excludeFromIndex
(CmsObject cms, CmsResource resource) Checks if the provided resource should be excluded from this search index.getContentIfUnchanged
(CmsResource resource) The method should return the extraction result of a content from the index, if sure the content has not changed since last indexing.Returns the document type factory used for the given resource in this index, ornull
in case the resource is not indexed by this index.Returns the search field configuration of this index.Returns the name of the field configuration used for this index.getIndexWriter
(I_CmsReport report, boolean create) Returns a new index writer for this index.Returns the language locale of this index.getLocaleForResource
(CmsObject cms, CmsResource resource, List<Locale> availableLocales) Returns the language locale for the given resource in this index.getName()
Gets the name of this index.getPath()
Returns the path where this index stores it's data in the "real" file system.Gets the project of this index.Get the rebuild mode of this index.Returns all configured sources names of this search index.Returns all configured index sources of this search index.void
Initializes the search index.boolean
Returnstrue
if this index is currently disabled.boolean
Returnstrue
if full text is extracted by this index.boolean
Returns a flag, indicating if the search index is successfully initialized.boolean
Returns the languageDetection.boolean
Returnstrue
in case this index is updated incremental.void
onIndexChanged
(boolean force) Method called by the search manager if the index has changed.void
removeSourceName
(String sourceName) Removes an index source from this search index.void
setEnabled
(boolean enabled) Can be used to enable / disable this index.void
setFieldConfigurationName
(String fieldConfigurationName) Sets the name of the field configuration used for this index.void
Sets the locale to index resources.void
setLocaleString
(String locale) Sets the locale to index resources as a String.void
Sets the logical key/name of this search index.void
setProject
(String project) Sets the name of the project used to index resources.void
setRebuildMode
(String rebuildMode) Sets the rebuild mode of this search index.void
shutDown()
Shuts down the search index.Methods inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
addConfigurationParameter, getConfiguration, initConfiguration
-
Field Details
-
REBUILD_MODE_AUTO
Automatic ("auto") index rebuild mode.- See Also:
-
REBUILD_MODE_MANUAL
Manual ("manual") index rebuild mode.- See Also:
-
REBUILD_MODE_OFFLINE
Offline ("offline") index rebuild mode.- See Also:
-
REBUILD_MODE_NEVER
Never ("never") index rebuild mode for indexes that should never be updated via OpenCms.- See Also:
-
-
Method Details
-
getContentIfUnchanged
The method should return the extraction result of a content from the index, if sure the content has not changed since last indexing. This will prevent re-extraction of the content. Preventing re-extraction saves time while indexing, e.g., if only meta-data of a content has changed. If no up-to-date content can be provided from the index, returnnull
.- Parameters:
resource
- the resource the content should be provided for.- Returns:
- the up-to-date extraction result as gained from the index - if possible, or
null
, if no up-to-date extraction result can be obtained from the index.
-
getFieldConfigurationName
Returns the name of the field configuration used for this index.- Returns:
- the name of the field configuration used for this index
-
getLocaleForResource
Returns the language locale for the given resource in this index.- Parameters:
cms
- the current OpenCms user contextresource
- the resource to checkavailableLocales
- a list of locales supported by the resource- Returns:
- the language locale for the given resource in this index
-
getSourceNames
Returns all configured sources names of this search index.- Returns:
- a list with all configured sources names of this search index
-
isExtractingContent
boolean isExtractingContent()Returnstrue
if full text is extracted by this index.Full text content extraction can be turned off in the index search configuration parameters in
opencms-search.xml
. Not extraction the full text information will highly improve performance.- Returns:
true
if full text is extracted by this index
-
isLanguageDetection
boolean isLanguageDetection()Returns the languageDetection.- Returns:
- the languageDetection
-
isUpdatedIncremental
boolean isUpdatedIncremental()Returnstrue
in case this index is updated incremental.An index is updated incremental if the index rebuild mode as defined by
getRebuildMode()
is either set to "auto" or "offline". Moreover, at least one update must have been written to the index already.- Returns:
true
in case this index is updated incremental
-
removeSourceName
Removes an index source from this search index.- Parameters:
sourceName
- the index source name to remove
-
setLocale
Sets the locale to index resources.- Parameters:
locale
- the locale to index resources
-
addSourceName
Adds am index source to this search index.- Parameters:
sourceName
- the index source name to add
-
checkConfiguration
Checks is this index has been configured correctly.In case the check fails, the
enabled
property is set tofalse
- Parameters:
cms
- a OpenCms user context to perform the checks with (should have "Administrator" permissions)- Returns:
true
in case the index is correctly configured and enabled after the check- See Also:
-
createEmptyDocument
Creates an empty document that can be used by this search field configuration.- Parameters:
resource
- the resource to create the document for- Returns:
- a new and empty document
-
excludeFromIndex
Checks if the provided resource should be excluded from this search index.- Parameters:
cms
- the OpenCms context used for building the search indexresource
- the resource to index- Returns:
- true if the resource should be excluded, false if it should be included in this index
-
getDocumentFactory
Returns the document type factory used for the given resource in this index, ornull
in case the resource is not indexed by this index.A resource is indexed if the following is all true:
- The index contains at last one index source matching the root path of the given resource.
- For this matching index source, the document type factory needed by the resource is also configured.
- Parameters:
res
- the resource to check- Returns:
- he document type factory used for the given resource in this index, or
null
in case the resource is not indexed by this index
-
getFieldConfiguration
Returns the search field configuration of this index.- Returns:
- the search field configuration of this index
-
getIndexWriter
Returns a new index writer for this index.- Parameters:
report
- the report to write error messages oncreate
- iftrue
a whole new index is created, iffalse
an existing index is updated- Returns:
- a new instance of IndexWriter
- Throws:
CmsIndexException
- if the index can not be opened
-
getLocale
Returns the language locale of this index.- Returns:
- the language locale of this index, for example "en"
-
getName
Gets the name of this index.- Returns:
- the name of the index
-
getPath
Returns the path where this index stores it's data in the "real" file system.- Returns:
- the path where this index stores it's data in the "real" file system
-
getProject
Gets the project of this index.- Returns:
- the project of the index, i.e. "online"
-
getRebuildMode
Get the rebuild mode of this index.- Returns:
- the current rebuild mode
-
getSources
Returns all configured index sources of this search index.- Returns:
- all configured index sources of this search index
-
initialize
Initializes the search index.- Throws:
CmsSearchException
- if the index source association failed or a configuration error occurred
-
isEnabled
boolean isEnabled()Returnstrue
if this index is currently disabled.- Returns:
true
if this index is currently disabled
-
isInitialized
boolean isInitialized()Returns a flag, indicating if the search index is successfully initialized.- Returns:
- a flag, indicating if the search index is successfully initialized.
-
onIndexChanged
Method called by the search manager if the index has changed. Typically the index searcher is reset when the method is called.- Parameters:
force
- iffalse
the index might decide itself it it has to act on the change, iftrue
it should act, even if itself cannot detect an index change.
-
setEnabled
Can be used to enable / disable this index.- Parameters:
enabled
- the state of the index to set
-
setFieldConfigurationName
Sets the name of the field configuration used for this index.- Parameters:
fieldConfigurationName
- the name of the field configuration to set
-
setLocaleString
Sets the locale to index resources as a String.- Parameters:
locale
- the locale to index resources- See Also:
-
setName
Sets the logical key/name of this search index.- Parameters:
name
- the logical key/name of this search index- Throws:
CmsIllegalArgumentException
- if the given name is null, empty or already taken by another search index
-
setProject
Sets the name of the project used to index resources.- Parameters:
project
- the name of the project used to index resources
-
setRebuildMode
Sets the rebuild mode of this search index.- Parameters:
rebuildMode
- the rebuild mode of this search index {auto|manual}
-
shutDown
void shutDown()Shuts down the search index.This will close the local Lucene index searcher instance.
-