public abstract class A_CmsSearchIndex extends java.lang.Object implements I_CmsSearchIndex
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROPERTY_SEARCH_EXCLUDE_VALUE_ALL
Special value for the search.exclude property.
|
static java.lang.String |
PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY
Special value for the search.exclude property.
|
static java.lang.String |
USE_ALL_LOCALE
The use all locale.
|
REBUILD_MODE_AUTO, REBUILD_MODE_MANUAL, REBUILD_MODE_NEVER, REBUILD_MODE_OFFLINE
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
Constructor and Description |
---|
A_CmsSearchIndex()
Default constructor only intended to be used by the XML configuration.
|
A_CmsSearchIndex(java.lang.String name)
Creates a new CmsSearchIndex with the given name.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfigurationParameter(java.lang.String key,
java.lang.String value)
Adds a configuration parameter to this parameter configurable class instance.
|
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.
|
protected abstract I_CmsIndexWriter |
createIndexWriter(boolean create,
I_CmsReport report)
Creates a new index writer.
|
boolean |
equals(java.lang.Object obj) |
boolean |
excludeFromIndex(CmsObject cms,
CmsResource resource)
Checks if the provided resource should be excluded from this search index.
|
CmsParameterConfiguration |
getConfiguration()
Returns the empty configuration.
|
I_CmsExtractionResult |
getContentIfUnchanged(CmsResource resource)
We always assume we have no unchanged copy of the content, since it depends on the concrete index.
|
I_CmsDocumentFactory |
getDocumentFactory(CmsResource res)
Returns the document type factory used for the given resource in this index, or
null
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.
|
int |
hashCode() |
void |
initConfiguration()
Initializes a configuration after all parameters have been added.
|
void |
initialize()
Initializes the search index.
|
boolean |
isEnabled()
Returns
true if this index is currently disabled. |
boolean |
isExtractingContent()
Returns
true if full text is extracted by this index. |
protected boolean |
isIndexing(CmsResource res)
Checks if the given resource should be indexed by this index or not.
|
boolean |
isInitialized()
Returns a flag, indicating if the search index is successfully initialized.
|
boolean |
isLanguageDetection()
Returns the languageDetection.
|
boolean |
isUpdatedIncremental()
Returns
true 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.
|
protected void |
setExtractContent(boolean extract)
Sets a flag, indicating if the index should extract content.
|
void |
setFieldConfiguration(I_CmsSearchFieldConfiguration fieldConfiguration)
Sets the field configuration used for this index.
|
void |
setFieldConfigurationName(java.lang.String fieldConfigurationName)
Sets the name of the field configuration used for this index.
|
protected void |
setIndexWriter(I_CmsIndexWriter writer)
Sets the index writer.
|
void |
setLanguageDetection(boolean languageDetection)
Sets the languageDetection.
|
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 |
setPath(java.lang.String path)
Set the path to the index/core.
|
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.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
createEmptyDocument
public static final java.lang.String PROPERTY_SEARCH_EXCLUDE_VALUE_ALL
public static final java.lang.String PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY
public static final java.lang.String USE_ALL_LOCALE
public A_CmsSearchIndex()
It is recommended to use the constructor
as it enforces the mandatory name argument. A_CmsSearchIndex(String)
public A_CmsSearchIndex(java.lang.String name) throws CmsIllegalArgumentException
name
- the system-wide unique name for the search indexCmsIllegalArgumentException
- if the given name is null, empty or already taken by another search indexpublic void addConfigurationParameter(java.lang.String key, java.lang.String value)
I_CmsConfigurationParameterHandler
addConfigurationParameter
in interface I_CmsConfigurationParameterHandler
key
- the name of the parametervalue
- the value for the parameterI_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)
public void addSourceName(java.lang.String sourceName)
addSourceName
in interface I_CmsSearchIndex
sourceName
- the index source name to addpublic boolean checkConfiguration(CmsObject cms)
I_CmsSearchIndex
In case the check fails, the enabled
property
is set to false
checkConfiguration
in interface I_CmsSearchIndex
cms
- a OpenCms user context to perform the checks with (should have "Administrator" permissions)true
in case the index is correctly configured and enabled after the checkI_CmsSearchIndex.checkConfiguration(org.opencms.file.CmsObject)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public boolean excludeFromIndex(CmsObject cms, CmsResource resource)
excludeFromIndex
in interface I_CmsSearchIndex
cms
- the OpenCms context used for building the search indexresource
- the resource to indexpublic CmsParameterConfiguration getConfiguration()
getConfiguration
in interface I_CmsConfigurationParameterHandler
null
if the class does not need any parametersI_CmsConfigurationParameterHandler.getConfiguration()
public I_CmsExtractionResult getContentIfUnchanged(CmsResource resource)
CmsSearchIndex.getContentIfUnchanged(CmsResource)
for an example.getContentIfUnchanged
in interface I_CmsSearchIndex
resource
- the resource the content should be provided for.null
,
if no up-to-date extraction result can be obtained from the index.I_CmsSearchIndex.getContentIfUnchanged(org.opencms.file.CmsResource)
public I_CmsDocumentFactory getDocumentFactory(CmsResource res)
null
in case the resource is not indexed by this index.A resource is indexed if the following is all true:
getDocumentFactory
in interface I_CmsSearchIndex
res
- the resource to checknull
in case the resource is not indexed by this indexpublic I_CmsSearchFieldConfiguration getFieldConfiguration()
I_CmsSearchIndex
getFieldConfiguration
in interface I_CmsSearchIndex
I_CmsSearchIndex.getFieldConfiguration()
public java.lang.String getFieldConfigurationName()
I_CmsSearchIndex
getFieldConfigurationName
in interface I_CmsSearchIndex
I_CmsSearchIndex.getFieldConfigurationName()
public I_CmsIndexWriter getIndexWriter(I_CmsReport report, boolean create) throws CmsIndexException
getIndexWriter
in interface I_CmsSearchIndex
report
- the report to write error messages oncreate
- if true
a whole new index is created, if false
an existing index is updatedCmsIndexException
- if the index can not be openedpublic java.util.Locale getLocale()
getLocale
in interface I_CmsSearchIndex
public java.util.Locale getLocaleForResource(CmsObject cms, CmsResource resource, java.util.List<java.util.Locale> availableLocales)
getLocaleForResource
in interface I_CmsSearchIndex
cms
- the current OpenCms user contextresource
- the resource to checkavailableLocales
- a list of locales supported by the resourcepublic java.lang.String getName()
I_CmsSearchIndex
getName
in interface I_CmsSearchIndex
I_CmsSearchIndex.getName()
public java.lang.String getPath()
I_CmsSearchIndex
getPath
in interface I_CmsSearchIndex
I_CmsSearchIndex.getPath()
public java.lang.String getProject()
I_CmsSearchIndex
getProject
in interface I_CmsSearchIndex
I_CmsSearchIndex.getProject()
public java.lang.String getRebuildMode()
I_CmsSearchIndex
getRebuildMode
in interface I_CmsSearchIndex
I_CmsSearchIndex.getRebuildMode()
public java.util.List<java.lang.String> getSourceNames()
I_CmsSearchIndex
getSourceNames
in interface I_CmsSearchIndex
I_CmsSearchIndex.getSourceNames()
public java.util.List<CmsSearchIndexSource> getSources()
I_CmsSearchIndex
getSources
in interface I_CmsSearchIndex
I_CmsSearchIndex.getSources()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public void initConfiguration()
I_CmsConfigurationParameterHandler
initConfiguration
in interface I_CmsConfigurationParameterHandler
I_CmsConfigurationParameterHandler.initConfiguration()
public void initialize() throws CmsSearchException
initialize
in interface I_CmsSearchIndex
CmsSearchException
- if the index source association failed or a configuration error occurredpublic boolean isEnabled()
I_CmsSearchIndex
true
if this index is currently disabled.isEnabled
in interface I_CmsSearchIndex
true
if this index is currently disabledI_CmsSearchIndex.isEnabled()
public boolean isExtractingContent()
I_CmsSearchIndex
true
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.
isExtractingContent
in interface I_CmsSearchIndex
true
if full text is extracted by this indexI_CmsSearchIndex.isExtractingContent()
public boolean isInitialized()
I_CmsSearchIndex
isInitialized
in interface I_CmsSearchIndex
I_CmsSearchIndex.isInitialized()
public boolean isLanguageDetection()
I_CmsSearchIndex
isLanguageDetection
in interface I_CmsSearchIndex
I_CmsSearchIndex.isLanguageDetection()
public boolean isUpdatedIncremental()
true
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 or
. Moreover, at least one update must have
been written to the index already.
isUpdatedIncremental
in interface I_CmsSearchIndex
true
in case this index is updated incrementalpublic void onIndexChanged(boolean force)
I_CmsSearchIndex
onIndexChanged
in interface I_CmsSearchIndex
force
- if false
the index might decide itself it it has to act on the change,
if true
it should act, even if itself cannot detect an index change.I_CmsSearchIndex.onIndexChanged(boolean)
public void removeSourceName(java.lang.String sourceName)
I_CmsSearchIndex
removeSourceName
in interface I_CmsSearchIndex
sourceName
- the index source name to removeI_CmsSearchIndex.removeSourceName(String)
public void setEnabled(boolean enabled)
I_CmsSearchIndex
setEnabled
in interface I_CmsSearchIndex
enabled
- the state of the index to setI_CmsSearchIndex.setEnabled(boolean)
public void setFieldConfiguration(I_CmsSearchFieldConfiguration fieldConfiguration)
fieldConfiguration
- the field configuration to setpublic void setFieldConfigurationName(java.lang.String fieldConfigurationName)
setFieldConfigurationName
in interface I_CmsSearchIndex
fieldConfigurationName
- the name of the field configuration to setpublic void setLanguageDetection(boolean languageDetection)
languageDetection
- the languageDetection to setpublic void setLocale(java.util.Locale locale)
I_CmsSearchIndex
setLocale
in interface I_CmsSearchIndex
locale
- the locale to index resourcesI_CmsSearchIndex.setLocale(java.util.Locale)
public void setLocaleString(java.lang.String locale)
I_CmsSearchIndex
setLocaleString
in interface I_CmsSearchIndex
locale
- the locale to index resourcesI_CmsSearchIndex.setLocaleString(java.lang.String)
public void setName(java.lang.String name) throws CmsIllegalArgumentException
I_CmsSearchIndex
setName
in interface I_CmsSearchIndex
name
- the logical key/name of this search indexCmsIllegalArgumentException
- if the given name is null, empty or already taken by another search indexI_CmsSearchIndex.setName(java.lang.String)
public void setPath(java.lang.String path)
path
- to the index/core.public void setProject(java.lang.String project)
I_CmsSearchIndex
setProject
in interface I_CmsSearchIndex
project
- the name of the project used to index resourcesI_CmsSearchIndex.setProject(java.lang.String)
public void setRebuildMode(java.lang.String rebuildMode)
I_CmsSearchIndex
setRebuildMode
in interface I_CmsSearchIndex
rebuildMode
- the rebuild mode of this search index {auto|manual}I_CmsSearchIndex.setRebuildMode(java.lang.String)
public void shutDown()
I_CmsSearchIndex
This will close the local Lucene index searcher instance.
shutDown
in interface I_CmsSearchIndex
I_CmsSearchIndex.shutDown()
protected abstract I_CmsIndexWriter createIndexWriter(boolean create, I_CmsReport report) throws CmsIndexException
create
- if true
a whole new index is created, if false
an existing index is updatedreport
- the reportCmsIndexException
- in case the writer could not be createdgetIndexWriter(I_CmsReport, boolean)
protected boolean isIndexing(CmsResource res)
res
- the resource candidatetrue
if the given resource should be indexed or false
if notprotected void setExtractContent(boolean extract)
extract
- a flag, indicating if the index should extract content.protected void setIndexWriter(I_CmsIndexWriter writer)
writer
- the index writer to set