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_OFFLINEADD_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, waitcreateEmptyDocumentpublic 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_CmsConfigurationParameterHandleraddConfigurationParameter in interface I_CmsConfigurationParameterHandlerkey - 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_CmsSearchIndexsourceName - 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_CmsSearchIndexcms - 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.ObjectObject.equals(java.lang.Object)public boolean excludeFromIndex(CmsObject cms, CmsResource resource)
excludeFromIndex in interface I_CmsSearchIndexcms - the OpenCms context used for building the search indexresource - the resource to indexpublic CmsParameterConfiguration getConfiguration()
getConfiguration in interface I_CmsConfigurationParameterHandlernull 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_CmsSearchIndexresource - 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_CmsSearchIndexres - the resource to checknull
in case the resource is not indexed by this indexpublic I_CmsSearchFieldConfiguration getFieldConfiguration()
I_CmsSearchIndexgetFieldConfiguration in interface I_CmsSearchIndexI_CmsSearchIndex.getFieldConfiguration()public java.lang.String getFieldConfigurationName()
I_CmsSearchIndexgetFieldConfigurationName in interface I_CmsSearchIndexI_CmsSearchIndex.getFieldConfigurationName()public I_CmsIndexWriter getIndexWriter(I_CmsReport report, boolean create) throws CmsIndexException
getIndexWriter in interface I_CmsSearchIndexreport - 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_CmsSearchIndexpublic java.util.Locale getLocaleForResource(CmsObject cms, CmsResource resource, java.util.List<java.util.Locale> availableLocales)
getLocaleForResource in interface I_CmsSearchIndexcms - the current OpenCms user contextresource - the resource to checkavailableLocales - a list of locales supported by the resourcepublic java.lang.String getName()
I_CmsSearchIndexgetName in interface I_CmsSearchIndexI_CmsSearchIndex.getName()public java.lang.String getPath()
I_CmsSearchIndexgetPath in interface I_CmsSearchIndexI_CmsSearchIndex.getPath()public java.lang.String getProject()
I_CmsSearchIndexgetProject in interface I_CmsSearchIndexI_CmsSearchIndex.getProject()public java.lang.String getRebuildMode()
I_CmsSearchIndexgetRebuildMode in interface I_CmsSearchIndexI_CmsSearchIndex.getRebuildMode()public java.util.List<java.lang.String> getSourceNames()
I_CmsSearchIndexgetSourceNames in interface I_CmsSearchIndexI_CmsSearchIndex.getSourceNames()public java.util.List<CmsSearchIndexSource> getSources()
I_CmsSearchIndexgetSources in interface I_CmsSearchIndexI_CmsSearchIndex.getSources()public int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public void initConfiguration()
I_CmsConfigurationParameterHandlerinitConfiguration in interface I_CmsConfigurationParameterHandlerI_CmsConfigurationParameterHandler.initConfiguration()public void initialize() throws CmsSearchException
initialize in interface I_CmsSearchIndexCmsSearchException - if the index source association failed or a configuration error occurredpublic boolean isEnabled()
I_CmsSearchIndextrue if this index is currently disabled.isEnabled in interface I_CmsSearchIndextrue if this index is currently disabledI_CmsSearchIndex.isEnabled()public boolean isExtractingContent()
I_CmsSearchIndextrue 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_CmsSearchIndextrue if full text is extracted by this indexI_CmsSearchIndex.isExtractingContent()public boolean isInitialized()
I_CmsSearchIndexisInitialized in interface I_CmsSearchIndexI_CmsSearchIndex.isInitialized()public boolean isLanguageDetection()
I_CmsSearchIndexisLanguageDetection in interface I_CmsSearchIndexI_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_CmsSearchIndextrue in case this index is updated incrementalpublic void onIndexChanged(boolean force)
I_CmsSearchIndexonIndexChanged in interface I_CmsSearchIndexforce - 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_CmsSearchIndexremoveSourceName in interface I_CmsSearchIndexsourceName - the index source name to removeI_CmsSearchIndex.removeSourceName(String)public void setEnabled(boolean enabled)
I_CmsSearchIndexsetEnabled in interface I_CmsSearchIndexenabled - 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_CmsSearchIndexfieldConfigurationName - the name of the field configuration to setpublic void setLanguageDetection(boolean languageDetection)
languageDetection - the languageDetection to setpublic void setLocale(java.util.Locale locale)
I_CmsSearchIndexsetLocale in interface I_CmsSearchIndexlocale - the locale to index resourcesI_CmsSearchIndex.setLocale(java.util.Locale)public void setLocaleString(java.lang.String locale)
I_CmsSearchIndexsetLocaleString in interface I_CmsSearchIndexlocale - the locale to index resourcesI_CmsSearchIndex.setLocaleString(java.lang.String)public void setName(java.lang.String name) throws CmsIllegalArgumentException
I_CmsSearchIndexsetName in interface I_CmsSearchIndexname - 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_CmsSearchIndexsetProject in interface I_CmsSearchIndexproject - the name of the project used to index resourcesI_CmsSearchIndex.setProject(java.lang.String)public void setRebuildMode(java.lang.String rebuildMode)
I_CmsSearchIndexsetRebuildMode in interface I_CmsSearchIndexrebuildMode - the rebuild mode of this search index {auto|manual}I_CmsSearchIndex.setRebuildMode(java.lang.String)public void shutDown()
I_CmsSearchIndexThis will close the local Lucene index searcher instance.
shutDown in interface I_CmsSearchIndexI_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