public class CmsSearchIndex extends java.lang.Object implements I_CmsConfigurationParameterHandler
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
A_PARAM_PREFIX
A constant for the full qualified name of the CmsSearchIndex class.
|
static java.lang.String |
BACKUP_REINDEXING
Constant for additional parameter to enable optimized full index regeneration (default: false).
|
static java.lang.String[] |
DATES
Look table to quickly zero-pad days / months in date Strings.
|
static java.lang.String[] |
DOC_META_FIELDS
Constant for a field list that contains the "meta" field as well as the "content" field.
|
static java.lang.String |
EXCERPT
Constant for additional parameter to enable excerpt creation (default: true).
|
static java.lang.String |
EXTRACT_CONTENT
Constant for additional parameter for index content extraction.
|
static java.lang.String |
IGNORE_EXPIRATION
Constant for additional parameter to enable/disable language detection (default: false).
|
static java.lang.String |
LANGUAGEDETECTION
Constant for additional parameter to enable/disable language detection (default: false).
|
static java.lang.String |
LUCENE_AUTO_COMMIT
Constant for additional parameter for the Lucene index setting.
|
static java.lang.String |
LUCENE_RAM_BUFFER_SIZE_MB
Constant for additional parameter for the Lucene index setting.
|
static org.apache.lucene.util.Version |
LUCENE_VERSION
The Lucene Version used to create Query parsers and such.
|
static java.lang.String |
MAX_HITS
Constant for additional parameter for controlling how many hits are loaded at maximum (default: 1000).
|
static int |
MAX_HITS_DEFAULT
Indicates how many hits are loaded at maximum by default.
|
static int |
MAX_YEAR_RANGE
Constant for years max range span in document search.
|
static java.lang.String |
PERMISSIONS
Constant for additional parameter to enable permission checks (default: true).
|
static java.lang.String |
PRIORITY
Constant for additional parameter to set the thread priority during search.
|
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 |
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_OFFLINE
Offline ("offline") index rebuild mode.
|
static java.lang.String |
TIME_RANGE
Constant for additional parameter to enable time range checks (default: true).
|
static java.lang.String |
TYPE_XMLCONTENT
The document type name for XML contents.
|
static java.lang.String |
USE_ALL_LOCALE
The use all locale.
|
protected static org.apache.lucene.index.StoredFieldVisitor |
VISITOR
A stored field visitor, that does not return the large fields: "content" and "contentblob".
|
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
构造器和说明 |
---|
CmsSearchIndex()
Default constructor only intended to be used by the XML configuration.
|
CmsSearchIndex(java.lang.String name)
Creates a new CmsSearchIndex with the given name.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addConfigurationParameter(java.lang.String key,
java.lang.String value)
Adds a parameter.
|
void |
addSourceName(java.lang.String sourceName)
Adds am index source to this search index.
|
protected org.apache.lucene.queries.BooleanFilter |
appendCategoryFilter(CmsObject cms,
org.apache.lucene.queries.BooleanFilter filter,
java.util.List<java.lang.String> categories)
Appends the a category filter to the given filter clause that matches all given categories.
|
protected org.apache.lucene.queries.BooleanFilter |
appendDateCreatedFilter(org.apache.lucene.queries.BooleanFilter filter,
long startTime,
long endTime)
Appends a date of creation filter to the given filter clause that matches the
given time range.
|
protected org.apache.lucene.queries.BooleanFilter |
appendDateLastModifiedFilter(org.apache.lucene.queries.BooleanFilter filter,
long startTime,
long endTime)
Appends a date of last modification filter to the given filter clause that matches the
given time range.
|
protected org.apache.lucene.queries.BooleanFilter |
appendPathFilter(CmsObject cms,
org.apache.lucene.queries.BooleanFilter filter,
java.util.List<java.lang.String> roots)
Appends the a VFS path filter to the given filter clause that matches all given root paths.
|
protected org.apache.lucene.queries.BooleanFilter |
appendResourceTypeFilter(CmsObject cms,
org.apache.lucene.queries.BooleanFilter filter,
java.util.List<java.lang.String> resourceTypes)
Appends the a resource type filter to the given filter clause that matches all given resource types.
|
boolean |
checkConfiguration(CmsObject cms)
Checks is this index has been configured correctly.
|
protected org.apache.lucene.search.Filter |
createDateRangeFilter(java.lang.String fieldName,
long startTime,
long endTime)
Creates an optimized date range filter for the date of last modification or creation.
|
I_CmsSearchDocument |
createEmptyDocument(CmsResource resource)
Creates an empty document that can be used by this search field configuration.
|
protected java.lang.String |
createIndexBackup()
Creates a backup of this index for optimized re-indexing of the whole content.
|
protected I_CmsIndexWriter |
createIndexWriter(boolean create,
I_CmsReport report)
Creates a new index writer.
|
boolean |
equals(java.lang.Object obj) |
protected boolean |
excludeFromIndex(CmsObject cms,
CmsResource resource)
Checks if the provided resource should be excluded from this search index.
|
protected void |
extendPathFilter(java.util.List<org.apache.lucene.index.Term> terms,
java.lang.String searchRoot)
Extends the given path query with another term for the given search root element.
|
protected java.lang.String |
generateIndexDirectory()
Generates the directory on the RFS for this index.
|
org.apache.lucene.analysis.Analyzer |
getAnalyzer()
Returns the Lucene analyzer used for this index.
|
CmsParameterConfiguration |
getConfiguration()
Returns the parameters of this configurable class instance,
or
null if the class does not need any parameters. |
static java.util.List<java.lang.String> |
getDateRangeSpan(long startDate,
long endDate)
Generates a list of date terms for the optimized date range search with "daily" granularity level.
|
I_CmsSearchDocument |
getDocument(int docId)
Returns a document by document ID.
|
org.apache.lucene.document.Document |
getDocument(java.lang.String rootPath)
已过时。
Use
getDocument(String, String) instead and provide CmsSearchField.FIELD_PATH as field to search in |
I_CmsSearchDocument |
getDocument(java.lang.String field,
java.lang.String term)
Returns the first document where the given term matches the selected index field.
|
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. |
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 |
getLocaleString()
Returns the language locale of the index as a String.
|
int |
getMaxHits()
Indicates the number of how many hits are loaded at maximum.
|
protected org.apache.lucene.search.Filter |
getMultiTermQueryFilter(java.lang.String field,
java.util.List<java.lang.String> terms)
Returns a cached Lucene term query filter for the given field and terms.
|
protected org.apache.lucene.search.Filter |
getMultiTermQueryFilter(java.lang.String field,
java.lang.String terms)
Returns a cached Lucene term query filter for the given field and terms.
|
protected org.apache.lucene.search.Filter |
getMultiTermQueryFilter(java.lang.String field,
java.lang.String termsStr,
java.util.List<java.lang.String> termsList)
Returns a cached Lucene term query filter for the given field and terms.
|
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.
|
int |
getPriority()
Returns the Thread priority for this search index.
|
java.lang.String |
getProject()
Gets the project of this index.
|
java.lang.String |
getRebuildMode()
Get the rebuild mode of this index.
|
protected CmsResource |
getResource(CmsObject cms,
I_CmsSearchDocument doc)
Checks if the OpenCms resource referenced by the result document can be read
by the user of the given OpenCms context.
|
org.apache.lucene.search.IndexSearcher |
getSearcher()
Returns the Lucene index searcher used for this search 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.
|
protected org.apache.lucene.search.Filter |
getTermQueryFilter(java.lang.String field,
java.lang.String term)
Returns a cached Lucene term query filter for the given field and term.
|
int |
hashCode() |
protected boolean |
hasReadPermission(CmsObject cms,
I_CmsSearchDocument doc)
Checks if the OpenCms resource referenced by the result document can be read
be the user of the given OpenCms context.
|
protected void |
indexSearcherClose()
Closes the index searcher for this index.
|
protected void |
indexSearcherClose(org.apache.lucene.search.IndexSearcher searcher)
Closes the given Lucene index searcher.
|
protected void |
indexSearcherOpen(java.lang.String path)
Initializes the index searcher for this index.
|
protected void |
indexSearcherUpdate()
Reopens the index search reader for this index, required after the index has been changed.
|
protected void |
indexWriterUnlock(I_CmsReport report)
Unlocks the Lucene index writer of this index if required.
|
void |
initConfiguration()
Initializes a configuration after all parameters have been added.
|
void |
initialize()
Initializes the search index.
|
boolean |
isBackupReindexing()
Returns
true if backup re-indexing is done by this index. |
boolean |
isCheckingPermissions()
Returns
true if permissions are checked for search results by this index. |
boolean |
isCheckingTimeRange()
Returns
true if the document time range is checked with a granularity level of seconds
for search results by this index. |
boolean |
isCheckPermissions()
Returns the checkPermissions.
|
boolean |
isCreatingExcerpt()
Returns
true if an excerpt is generated by this index. |
boolean |
isEnabled()
Returns
true if this index is currently disabled. |
boolean |
isExtractingContent()
Returns
true if full text is extracted by this index. |
boolean |
isIgnoreExpiration()
Returns the ignoreExpiration.
|
protected boolean |
isInTimeRange(org.apache.lucene.document.Document doc,
CmsSearchParameters params)
Checks if the document is in the time range specified in the search parameters.
|
boolean |
isLanguageDetection()
Returns the languageDetection.
|
boolean |
isRequireViewPermission()
Returns
true if a resource requires read permission to be included in the result list. |
protected boolean |
isSortScoring(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Sort sort)
Checks if the score for the results must be calculated based on the provided sort option.
|
boolean |
isUpdatedIncremental()
Returns
true in case this index is updated incremental. |
protected boolean |
needsPermissionCheck(I_CmsSearchDocument doc)
Checks if the OpenCms resource referenced by the result document needs to be checked.
|
protected void |
removeIndexBackup(java.lang.String path)
Removes the given backup folder of this index.
|
void |
removeSourceName(java.lang.String sourceName)
Removes an index source from this search index.
|
CmsSearchResultList |
search(CmsObject cms,
CmsSearchParameters params)
Performs a search on the index within the given fields.
|
void |
setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
Sets the Lucene analyzer used for this index.
|
void |
setCheckPermissions(boolean checkPermissions)
Sets the checkPermissions.
|
void |
setEnabled(boolean enabled)
Can be used to enable / disable this index.
|
void |
setFieldConfiguration(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.
|
void |
setIgnoreExpiration(boolean ignoreExpiration)
Sets the ignoreExpiration.
|
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 |
setMaxHits(int maxHits)
Sets the number of how many hits are loaded at maximum.
|
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 |
setRequireViewPermission(boolean requireViewPermission)
Controls if a resource requires view permission to be displayed in the result list.
|
void |
shutDown()
Shuts down the search index.
|
java.lang.String |
toString()
Returns the name (
) of this search index. |
public static final java.lang.String A_PARAM_PREFIX
public static final java.lang.String BACKUP_REINDEXING
public static final java.lang.String[] DATES
public static final java.lang.String[] DOC_META_FIELDS
public static final java.lang.String EXCERPT
public static final java.lang.String EXTRACT_CONTENT
public static final java.lang.String IGNORE_EXPIRATION
public static final java.lang.String LANGUAGEDETECTION
public static final java.lang.String LUCENE_AUTO_COMMIT
public static final java.lang.String LUCENE_RAM_BUFFER_SIZE_MB
public static final org.apache.lucene.util.Version LUCENE_VERSION
public static final java.lang.String MAX_HITS
public static final int MAX_HITS_DEFAULT
public static final int MAX_YEAR_RANGE
public static final java.lang.String PERMISSIONS
public static final java.lang.String PRIORITY
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 REBUILD_MODE_AUTO
public static final java.lang.String REBUILD_MODE_MANUAL
public static final java.lang.String REBUILD_MODE_OFFLINE
public static final java.lang.String TIME_RANGE
public static final java.lang.String TYPE_XMLCONTENT
public static final java.lang.String USE_ALL_LOCALE
protected static final org.apache.lucene.index.StoredFieldVisitor VISITOR
public CmsSearchIndex()
It is recommended to use the constructor
as it enforces the mandatory name argument. CmsSearchIndex(String)
public 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 static java.util.List<java.lang.String> getDateRangeSpan(long startDate, long endDate)
How this works:
startDate
- start date of the range to search inendDate
- end date of the range to search inpublic void addConfigurationParameter(java.lang.String key, java.lang.String value)
addConfigurationParameter
在接口中 I_CmsConfigurationParameterHandler
key
- the key/name of the parametervalue
- the value of the parameterpublic void addSourceName(java.lang.String sourceName)
sourceName
- the index source name to addpublic boolean checkConfiguration(CmsObject cms)
In case the check fails, the enabled
property
is set to false
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 checkisEnabled()
public I_CmsSearchDocument createEmptyDocument(CmsResource resource)
resource
- the resource to create the document forpublic boolean equals(java.lang.Object obj)
equals
在类中 java.lang.Object
Object.equals(java.lang.Object)
public org.apache.lucene.analysis.Analyzer getAnalyzer()
public CmsParameterConfiguration getConfiguration()
I_CmsConfigurationParameterHandler
null
if the class does not need any parameters.getConfiguration
在接口中 I_CmsConfigurationParameterHandler
null
if the class does not need any parametersI_CmsConfigurationParameterHandler.getConfiguration()
public I_CmsSearchDocument getDocument(int docId)
docId
- the id to get the document for@Deprecated public org.apache.lucene.document.Document getDocument(java.lang.String rootPath)
getDocument(String, String)
instead and provide CmsSearchField.FIELD_PATH
as field to search inrootPath
- the root path of the document to getpublic I_CmsSearchDocument getDocument(java.lang.String field, java.lang.String term)
Use this method to search for documents which have unique field values, like a unique id.
field
- the field to search interm
- the term to search forpublic 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:
res
- the resource to checknull
in case the resource is not indexed by this indexpublic CmsSearchFieldConfiguration getFieldConfiguration()
public java.lang.String getFieldConfigurationName()
public I_CmsIndexWriter getIndexWriter(I_CmsReport report, boolean create) throws CmsIndexException
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()
public java.util.Locale getLocaleForResource(CmsObject cms, CmsResource resource, java.util.List<java.util.Locale> availableLocales)
cms
- the current OpenCms user contextresource
- the resource to checkavailableLocales
- a list of locales supported by the resourcepublic java.lang.String getLocaleString()
getLocale()
public int getMaxHits()
The number of maximum documents to load from the index
must be specified. The default of this setting is MAX_HITS_DEFAULT
(5000).
This means that at maximum 5000 results are returned from the index.
Please note that this number may be reduced further because of OpenCms read permissions
or per-user file visibility settings not controlled in the index.
public java.lang.String getName()
public java.lang.String getPath()
public int getPriority()
public java.lang.String getProject()
public java.lang.String getRebuildMode()
public org.apache.lucene.search.IndexSearcher getSearcher()
public java.util.List<java.lang.String> getSourceNames()
public java.util.List<CmsSearchIndexSource> getSources()
public int hashCode()
hashCode
在类中 java.lang.Object
Object.hashCode()
public void initConfiguration()
I_CmsConfigurationParameterHandler
public void initialize() throws CmsSearchException
CmsSearchException
- if the index source association failed or a configuration error occurredpublic boolean isBackupReindexing()
true
if backup re-indexing is done by this index.This is an optimization method by which the old extracted content is reused in order to save performance when re-indexing.
true
if backup re-indexing is done by this indexpublic boolean isCheckingPermissions()
true
if permissions are checked for search results by this index.
If permission checks are not required, they can be turned off in the index search configuration parameters
in opencms-search.xml
. Not checking permissions will improve performance.
This is can be of use in scenarios when you know that all search results are always readable, which is usually true for public websites that do not have personalized accounts.
Please note that even if a result is returned where the current user has no read permissions, the user can not actually access this document. It will only appear in the search result list, but if the user clicks the link to open the document he will get an error.
true
if permissions are checked for search results by this indexpublic boolean isCheckingTimeRange()
true
if the document time range is checked with a granularity level of seconds
for search results by this index.
Since OpenCms 8.0, time range checks are always done if CmsSearchParameters.setMinDateLastModified(long)
or any of the corresponding methods are used.
This is done very efficiently using optimized Lucene filers.
However, the granularity of these checks are done only on a daily
basis, which means that you can only find "changes made yesterday" but not "changes made last hour".
For normal limitation of search results, a daily granularity should be enough.
If time range checks with a granularity level of seconds are required,
they can be turned on in the index search configuration parameters
in opencms-search.xml
.
Not checking the time range with a granularity level of seconds will improve performance.
By default the granularity level of seconds is turned off since OpenCms 8.0
true
if the document time range is checked with a granularity level of seconds for search results by this indexpublic boolean isCheckPermissions()
public boolean isCreatingExcerpt()
true
if an excerpt is generated by this index.
If no except is required, generation can be turned off in the index search configuration parameters
in opencms-search.xml
. Not generating an excerpt will improve performance.
true
if an excerpt is generated by this indexpublic boolean isEnabled()
true
if this index is currently disabled.true
if this index is currently disabledpublic boolean isExtractingContent()
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.
true
if full text is extracted by this indexpublic boolean isIgnoreExpiration()
public boolean isLanguageDetection()
public boolean isRequireViewPermission()
true
if a resource requires read permission to be included in the result list.true
if a resource requires read permission to be included in the result listpublic 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 "auto" or
"offline". Moreover, at least one update must have
been written to the index already.
true
in case this index is updated incrementalpublic void removeSourceName(java.lang.String sourceName)
sourceName
- the index source name to removepublic CmsSearchResultList search(CmsObject cms, CmsSearchParameters params) throws CmsSearchException
The result is returned as List with entries of type I_CmsSearchResult.
cms
- the current user's Cms objectparams
- the parameters to use for the searchCmsSearchException
- if something goes wrongpublic void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
analyzer
- the Lucene analyzer to setpublic void setCheckPermissions(boolean checkPermissions)
checkPermissions
- the checkPermissions to setpublic void setEnabled(boolean enabled)
enabled
- the state of the index to setpublic void setFieldConfiguration(CmsSearchFieldConfiguration fieldConfiguration)
fieldConfiguration
- the field configuration to setpublic void setFieldConfigurationName(java.lang.String fieldConfigurationName)
fieldConfigurationName
- the name of the field configuration to setpublic void setIgnoreExpiration(boolean ignoreExpiration)
ignoreExpiration
- the ignoreExpiration to setpublic void setLanguageDetection(boolean languageDetection)
languageDetection
- the languageDetection to setpublic void setLocale(java.util.Locale locale)
locale
- the locale to index resourcespublic void setLocaleString(java.lang.String locale)
locale
- the locale to index resourcessetLocale(Locale)
public void setMaxHits(int maxHits)
This must be set at least to 50, or this setting is ignored.
maxHits
- the number of how many hits are loaded at maximum to setgetMaxHits()
public void setName(java.lang.String name) throws CmsIllegalArgumentException
name
- the logical key/name of this search indexCmsIllegalArgumentException
- if the given name is null, empty or already taken by another search indexpublic void setProject(java.lang.String project)
project
- the name of the project used to index resourcespublic void setRebuildMode(java.lang.String rebuildMode)
rebuildMode
- the rebuild mode of this search index {auto|manual}public void setRequireViewPermission(boolean requireViewPermission)
By default this is false
.
requireViewPermission
- controls if a resource requires view permission to be displayed in the result listpublic void shutDown()
This will close the local Lucene index searcher instance.
public java.lang.String toString()
getName()
) of this search index.toString
在类中 java.lang.Object
getName()
) of this search indexObject.toString()
protected org.apache.lucene.queries.BooleanFilter appendCategoryFilter(CmsObject cms, org.apache.lucene.queries.BooleanFilter filter, java.util.List<java.lang.String> categories)
In case the provided List is null or empty, the original filter is left unchanged.
The original filter parameter is extended and also provided as return value.
cms
- the current OpenCms search contextfilter
- the filter to extendcategories
- the categories that will compose the filterprotected org.apache.lucene.queries.BooleanFilter appendDateCreatedFilter(org.apache.lucene.queries.BooleanFilter filter, long startTime, long endTime)
If the start time is equal to Long.MIN_VALUE
and the end time is equal to Long.MAX_VALUE
than the original filter is left unchanged.
The original filter parameter is extended and also provided as return value.
filter
- the filter to extendstartTime
- start time of the range to search inendTime
- end time of the range to search inprotected org.apache.lucene.queries.BooleanFilter appendDateLastModifiedFilter(org.apache.lucene.queries.BooleanFilter filter, long startTime, long endTime)
If the start time is equal to Long.MIN_VALUE
and the end time is equal to Long.MAX_VALUE
than the original filter is left unchanged.
The original filter parameter is extended and also provided as return value.
filter
- the filter to extendstartTime
- start time of the range to search inendTime
- end time of the range to search inprotected org.apache.lucene.queries.BooleanFilter appendPathFilter(CmsObject cms, org.apache.lucene.queries.BooleanFilter filter, java.util.List<java.lang.String> roots)
In case the provided List is null or empty, the current request context site root is appended.
The original filter parameter is extended and also provided as return value.
cms
- the current OpenCms search contextfilter
- the filter to extendroots
- the VFS root paths that will compose the filterprotected org.apache.lucene.queries.BooleanFilter appendResourceTypeFilter(CmsObject cms, org.apache.lucene.queries.BooleanFilter filter, java.util.List<java.lang.String> resourceTypes)
In case the provided List is null or empty, the original filter is left unchanged.
The original filter parameter is extended and also provided as return value.
cms
- the current OpenCms search contextfilter
- the filter to extendresourceTypes
- the resource types that will compose the filterprotected org.apache.lucene.search.Filter createDateRangeFilter(java.lang.String fieldName, long startTime, long endTime)
If the start date is equal to Long.MIN_VALUE
and the end date is equal to Long.MAX_VALUE
than null
is returned.
fieldName
- the name of the field to searchstartTime
- start time of the range to search inendTime
- end time of the range to search inprotected java.lang.String createIndexBackup()
null
in case no backup was createdprotected 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 excludeFromIndex(CmsObject cms, CmsResource resource)
cms
- the OpenCms context used for building the search indexresource
- the resource to indexprotected void extendPathFilter(java.util.List<org.apache.lucene.index.Term> terms, java.lang.String searchRoot)
terms
- the path filter to extendsearchRoot
- the search root to add to the path queryprotected java.lang.String generateIndexDirectory()
protected org.apache.lucene.search.Filter getMultiTermQueryFilter(java.lang.String field, java.util.List<java.lang.String> terms)
field
- the field to useterms
- the term to useprotected org.apache.lucene.search.Filter getMultiTermQueryFilter(java.lang.String field, java.lang.String terms)
field
- the field to useterms
- the term to useprotected org.apache.lucene.search.Filter getMultiTermQueryFilter(java.lang.String field, java.lang.String termsStr, java.util.List<java.lang.String> termsList)
field
- the field to usetermsStr
- the terms to use as a String separated by a space ' ' chartermsList
- the list of terms to useprotected CmsResource getResource(CmsObject cms, I_CmsSearchDocument doc)
CmsResource
or null
if
the user is not permitted to read the resource.cms
- the OpenCms user context to use for permission testingdoc
- the search result document to checkCmsResource
or null
if the user is not permittedprotected org.apache.lucene.search.Filter getTermQueryFilter(java.lang.String field, java.lang.String term)
field
- the field to useterm
- the term to useprotected boolean hasReadPermission(CmsObject cms, I_CmsSearchDocument doc)
cms
- the OpenCms user context to use for permission testingdoc
- the search result document to checktrue
if the user has read permissions to the resourceprotected void indexSearcherClose()
protected void indexSearcherClose(org.apache.lucene.search.IndexSearcher searcher)
searcher
- the searcher to closeprotected void indexSearcherOpen(java.lang.String path)
In case there is an index searcher still open, it is closed first.
For performance reasons, one instance of the index searcher should be kept for all searches. However, if the index is updated or changed this searcher instance needs to be re-initialized.
path
- the path to the index directoryprotected void indexSearcherUpdate()
protected void indexWriterUnlock(I_CmsReport report) throws CmsIndexException
report
- the report to write error messages onCmsIndexException
- if unlocking of the index is impossible for any reasonprotected boolean isInTimeRange(org.apache.lucene.document.Document doc, CmsSearchParameters params)
The creation date and/or the last modification date are checked.
doc
- the document to check the dates against the given time rangeparams
- the search parameters where the time ranges are specifiedprotected boolean isSortScoring(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Sort sort)
Since Lucene 3 apparently the score is no longer calculated by default, but only if the searcher is explicitly told so. This methods checks if, based on the given sort, the score must be calculated.
searcher
- the index searcher to preparesort
- the sort option to useprotected boolean needsPermissionCheck(I_CmsSearchDocument doc)
doc
- the search result document to checktrue
if the document needs to be checked false
otherwiseprotected void removeIndexBackup(java.lang.String path)
path
- the backup folder to removeprotected void setIndexWriter(I_CmsIndexWriter writer)
writer
- the index writer to set