Package org.opencms.search
Interface I_CmsSearchIndex
-
- All Superinterfaces:
I_CmsConfigurationParameterHandler
,java.io.Serializable
- All Known Implementing Classes:
A_CmsSearchIndex
,CmsSearchIndex
,CmsSolrIndex
public interface I_CmsSearchIndex extends I_CmsConfigurationParameterHandler, java.io.Serializable
Interface for search indizes that should be handled by theCmsSearchManager
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REBUILD_MODE_AUTO
Automatic ("auto") index rebuild mode.static java.lang.String
REBUILD_MODE_MANUAL
Manual ("manual") index rebuild mode.static java.lang.String
REBUILD_MODE_NEVER
Never ("never") index rebuild mode for indexes that should never be updated via OpenCms.static java.lang.String
REBUILD_MODE_OFFLINE
Offline ("offline") index rebuild mode.-
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addSourceName(java.lang.String sourceName)
Adds am index source to this search index.boolean
checkConfiguration(CmsObject cms)
Checks is this index has been configured correctly.I_CmsSearchDocument
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.I_CmsExtractionResult
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.I_CmsDocumentFactory
getDocumentFactory(CmsResource res)
Returns the document type factory used for the given resource in this index, ornull
in case the resource is not indexed by this index.I_CmsSearchFieldConfiguration
getFieldConfiguration()
Returns the search field configuration of this index.java.lang.String
getFieldConfigurationName()
Returns the name of the field configuration used for this index.I_CmsIndexWriter
getIndexWriter(I_CmsReport report, boolean create)
Returns a new index writer for this index.java.util.Locale
getLocale()
Returns the language locale of this index.java.util.Locale
getLocaleForResource(CmsObject cms, CmsResource resource, java.util.List<java.util.Locale> availableLocales)
Returns the language locale for the given resource in this index.java.lang.String
getName()
Gets the name of this index.java.lang.String
getPath()
Returns the path where this index stores it's data in the "real" file system.java.lang.String
getProject()
Gets the project of this index.java.lang.String
getRebuildMode()
Get the rebuild mode of this index.java.util.List<java.lang.String>
getSourceNames()
Returns all configured sources names of this search index.java.util.List<CmsSearchIndexSource>
getSources()
Returns all configured index sources of this search index.void
initialize()
Initializes the search index.boolean
isEnabled()
Returnstrue
if this index is currently disabled.boolean
isExtractingContent()
Returnstrue
if full text is extracted by this index.boolean
isInitialized()
Returns a flag, indicating if the search index is successfully initialized.boolean
isLanguageDetection()
Returns the languageDetection.boolean
isUpdatedIncremental()
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(java.lang.String sourceName)
Removes an index source from this search index.void
setEnabled(boolean enabled)
Can be used to enable / disable this index.void
setFieldConfigurationName(java.lang.String fieldConfigurationName)
Sets the name of the field configuration used for this index.void
setLocale(java.util.Locale locale)
Sets the locale to index resources.void
setLocaleString(java.lang.String locale)
Sets the locale to index resources as a String.void
setName(java.lang.String name)
Sets the logical key/name of this search index.void
setProject(java.lang.String project)
Sets the name of the project used to index resources.void
setRebuildMode(java.lang.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 Detail
-
REBUILD_MODE_AUTO
static final java.lang.String REBUILD_MODE_AUTO
Automatic ("auto") index rebuild mode.- See Also:
- Constant Field Values
-
REBUILD_MODE_MANUAL
static final java.lang.String REBUILD_MODE_MANUAL
Manual ("manual") index rebuild mode.- See Also:
- Constant Field Values
-
REBUILD_MODE_OFFLINE
static final java.lang.String REBUILD_MODE_OFFLINE
Offline ("offline") index rebuild mode.- See Also:
- Constant Field Values
-
REBUILD_MODE_NEVER
static final java.lang.String REBUILD_MODE_NEVER
Never ("never") index rebuild mode for indexes that should never be updated via OpenCms.- See Also:
- Constant Field Values
-
-
Method Detail
-
getContentIfUnchanged
I_CmsExtractionResult 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. 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
java.lang.String getFieldConfigurationName()
Returns the name of the field configuration used for this index.- Returns:
- the name of the field configuration used for this index
-
getLocaleForResource
java.util.Locale getLocaleForResource(CmsObject cms, CmsResource resource, java.util.List<java.util.Locale> availableLocales)
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
java.util.List<java.lang.String> 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
void removeSourceName(java.lang.String sourceName)
Removes an index source from this search index.- Parameters:
sourceName
- the index source name to remove
-
setLocale
void setLocale(java.util.Locale locale)
Sets the locale to index resources.- Parameters:
locale
- the locale to index resources
-
addSourceName
void addSourceName(java.lang.String sourceName)
Adds am index source to this search index.- Parameters:
sourceName
- the index source name to add
-
checkConfiguration
boolean checkConfiguration(CmsObject cms)
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:
isEnabled()
-
createEmptyDocument
I_CmsSearchDocument createEmptyDocument(CmsResource resource)
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
boolean excludeFromIndex(CmsObject cms, CmsResource resource)
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
I_CmsDocumentFactory getDocumentFactory(CmsResource res)
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
I_CmsSearchFieldConfiguration getFieldConfiguration()
Returns the search field configuration of this index.- Returns:
- the search field configuration of this index
-
getIndexWriter
I_CmsIndexWriter getIndexWriter(I_CmsReport report, boolean create) throws CmsIndexException
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
java.util.Locale getLocale()
Returns the language locale of this index.- Returns:
- the language locale of this index, for example "en"
-
getName
java.lang.String getName()
Gets the name of this index.- Returns:
- the name of the index
-
getPath
java.lang.String 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
java.lang.String getProject()
Gets the project of this index.- Returns:
- the project of the index, i.e. "online"
-
getRebuildMode
java.lang.String getRebuildMode()
Get the rebuild mode of this index.- Returns:
- the current rebuild mode
-
getSources
java.util.List<CmsSearchIndexSource> getSources()
Returns all configured index sources of this search index.- Returns:
- all configured index sources of this search index
-
initialize
void initialize() throws CmsSearchException
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
void onIndexChanged(boolean force)
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
void setEnabled(boolean enabled)
Can be used to enable / disable this index.- Parameters:
enabled
- the state of the index to set
-
setFieldConfigurationName
void setFieldConfigurationName(java.lang.String fieldConfigurationName)
Sets the name of the field configuration used for this index.- Parameters:
fieldConfigurationName
- the name of the field configuration to set
-
setLocaleString
void setLocaleString(java.lang.String locale)
Sets the locale to index resources as a String.- Parameters:
locale
- the locale to index resources- See Also:
setLocale(Locale)
-
setName
void setName(java.lang.String name) throws CmsIllegalArgumentException
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
void setProject(java.lang.String project)
Sets the name of the project used to index resources.- Parameters:
project
- the name of the project used to index resources
-
setRebuildMode
void setRebuildMode(java.lang.String rebuildMode)
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.
-
-