org.opencms.search.galleries
Class CmsGallerySearchIndex

java.lang.Object
  extended by org.opencms.search.CmsSearchIndex
      extended by org.opencms.search.galleries.CmsGallerySearchIndex
All Implemented Interfaces:
I_CmsConfigurationParameterHandler

public class CmsGallerySearchIndex
extends CmsSearchIndex

Implements the search within a the gallery index.

Since:
8.0.0

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opencms.search.CmsSearchIndex
CmsSearchIndex.LazyContentReader
 
Field Summary
static java.lang.String FOLDER_SYSTEM
          The system folder.
static java.lang.String FOLDER_SYSTEM_GALLERIES
          The system galleries path.
static java.lang.String FOLDER_SYTEM_MODULES
          The system modules folder path.
static java.lang.String GALLERY_INDEX_NAME
          The advanced gallery index name.
static java.lang.String TYPE_XMLCONTENT_GALLERIES
          The gallery document type name for xml-contents.
static java.lang.String TYPE_XMLPAGE_GALLERIES
          The gallery document type name for xml-pages.
 
Fields inherited from class org.opencms.search.CmsSearchIndex
A_LEGACY_PARAM_PREFIX, BACKUP_REINDEXING, DATES, DOC_META_FIELDS, EXCERPT, EXTRACT_CONTENT, LANGUAGEDETECTION, LUCENE_AUTO_COMMIT, LUCENE_MAX_MERGE_DOCS, LUCENE_MERGE_FACTOR, LUCENE_RAM_BUFFER_SIZE_MB, LUCENE_USE_COMPOUND_FILE, LUCENE_VERSION, MAX_HITS, MAX_HITS_DEFAULT, MAX_YEAR_RANGE, PERMISSIONS, PRIORITY, PROPERTY_SEARCH_EXCLUDE_VALUE_ALL, PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY, REBUILD_MODE_AUTO, REBUILD_MODE_MANUAL, REBUILD_MODE_OFFLINE, TIME_RANGE, TYPE_XMLCONTENT, USE_ALL_LOCALE
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Constructor Summary
CmsGallerySearchIndex()
          Default constructor only intended to be used by the XML configuration.
CmsGallerySearchIndex(java.lang.String name)
          Creates a new gallery search index with the given name.
 
Method Summary
protected  org.apache.lucene.search.BooleanFilter appendContainerTypeFilter(CmsObject cms, org.apache.lucene.search.BooleanFilter filter, java.util.List<java.lang.String> containers)
          Appends a container type filter to the given filter clause that matches all given container types.
protected  org.apache.lucene.search.BooleanFilter appendIgnoreSearchExclude(org.apache.lucene.search.BooleanFilter filter, boolean ignoreSearchExclude)
          Appends the ignore search exclude property filter.
protected  org.apache.lucene.search.BooleanFilter appendLocaleFilter(CmsObject cms, org.apache.lucene.search.BooleanFilter filter, java.lang.String locale)
          Appends the locale filter to the given filter clause that matches the given locale.
protected  org.apache.lucene.search.BooleanFilter appendPathFilter(CmsObject cms, org.apache.lucene.search.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  boolean excludeFromIndex(CmsObject cms, CmsResource resource)
          Checks if the provided resource should be excluded from this search index.
 I_CmsSearchDocument getDocument(CmsUUID structureId)
          Deprecated. Use CmsSearchIndex.getDocument(String, String) instead and provide CmsGallerySearchFieldMapping.FIELD_RESOURCE_STRUCTURE_ID as field to search in
 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.
protected  java.util.List<java.lang.String> getLocaleExtendedFields(java.util.List<java.lang.String> fields, java.util.Locale locale)
          Returns a list of locale extended field names.
 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.
protected  CmsResource getResource(CmsObject cms, I_CmsSearchDocument doc)
          We are overriding getResource since the default implementation uses the path to read the resource, which doesn't work for resources in a different site.
 java.util.List<java.lang.String> getSearchRootsForScope(CmsGallerySearchScope scope, java.lang.String siteParam, java.lang.String subSiteParam)
          Gets the search roots to use for the given site/subsite parameters.
 CmsGallerySearchResultList searchGallery(CmsObject cms, CmsGallerySearchParameters params)
          Performs a search on the gallery index.
 
Methods inherited from class org.opencms.search.CmsSearchIndex
addConfigurationParameter, addSourceName, appendCategoryFilter, appendDateCreatedFilter, appendDateLastModifiedFilter, appendResourceTypeFilter, checkConfiguration, createDateRangeFilter, createEmptyDocument, createIndexBackup, createIndexWriter, equals, extendPathFilter, generateIndexDirectory, getAnalyzer, getConfiguration, getDateRangeSpan, getDocument, getDocument, getFieldConfiguration, getFieldConfigurationName, getFieldSelector, getIndexWriter, getLocale, getLocaleString, getMaxHits, getMultiTermQueryFilter, getMultiTermQueryFilter, getMultiTermQueryFilter, getName, getPath, getPriority, getProject, getRebuildMode, getSearcher, getSourceNames, getSources, getTermQueryFilter, hashCode, hasReadPermission, indexSearcherClose, indexSearcherClose, indexSearcherOpen, indexSearcherUpdate, indexWriterUnlock, initConfiguration, initialize, isBackupReindexing, isCheckingPermissions, isCheckingTimeRange, isCheckPermissions, isCreatingExcerpt, isEnabled, isExtractingContent, isInTimeRange, isLanguageDetection, isRequireViewPermission, isUpdatedIncremental, needsPermissionCheck, prepareSortScoring, removeIndexBackup, removeSourceName, search, setAnalyzer, setCheckPermissions, setEnabled, setFieldConfiguration, setFieldConfigurationName, setIndexWriter, setLanguageDetection, setLocale, setLocaleString, setMaxHits, setName, setProject, setRebuildMode, setRequireViewPermission, shutDown, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FOLDER_SYSTEM

public static final java.lang.String FOLDER_SYSTEM
The system folder.

See Also:
Constant Field Values

FOLDER_SYSTEM_GALLERIES

public static final java.lang.String FOLDER_SYSTEM_GALLERIES
The system galleries path.

See Also:
Constant Field Values

FOLDER_SYTEM_MODULES

public static final java.lang.String FOLDER_SYTEM_MODULES
The system modules folder path.

See Also:
Constant Field Values

GALLERY_INDEX_NAME

public static final java.lang.String GALLERY_INDEX_NAME
The advanced gallery index name.

See Also:
Constant Field Values

TYPE_XMLCONTENT_GALLERIES

public static final java.lang.String TYPE_XMLCONTENT_GALLERIES
The gallery document type name for xml-contents.

See Also:
Constant Field Values

TYPE_XMLPAGE_GALLERIES

public static final java.lang.String TYPE_XMLPAGE_GALLERIES
The gallery document type name for xml-pages.

See Also:
Constant Field Values
Constructor Detail

CmsGallerySearchIndex

public CmsGallerySearchIndex()
Default constructor only intended to be used by the XML configuration.

It is recommended to use the constructor CmsGallerySearchIndex(String) as it enforces the mandatory name argument.


CmsGallerySearchIndex

public CmsGallerySearchIndex(java.lang.String name)
                      throws CmsIllegalArgumentException
Creates a new gallery search index with the given name.

Parameters:
name - the system-wide unique name for the search index
Throws:
CmsIllegalArgumentException - if the given name is null, empty or already taken by another search index
Method Detail

getDocument

@Deprecated
public I_CmsSearchDocument getDocument(CmsUUID structureId)
Deprecated. Use CmsSearchIndex.getDocument(String, String) instead and provide CmsGallerySearchFieldMapping.FIELD_RESOURCE_STRUCTURE_ID as field to search in

Returns the Lucene document with the given structure id from the index.

Parameters:
structureId - the structure id of the document to retrieve
Returns:
the Lucene document with the given root path from the index

getDocumentFactory

public I_CmsDocumentFactory getDocumentFactory(CmsResource res)
Description copied from class: CmsSearchIndex
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.

A resource is indexed if the following is all true:

  1. The index contains at last one index source matching the root path of the given resource.
  2. For this matching index source, the document type factory needed by the resource is also configured.

Overrides:
getDocumentFactory in class CmsSearchIndex
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
See Also:
CmsSearchIndex.getDocumentFactory(org.opencms.file.CmsResource)

getLocaleForResource

public 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.

Overrides:
getLocaleForResource in class CmsSearchIndex
Parameters:
cms - the current OpenCms user context
resource - the resource to check
availableLocales - a list of locales supported by the resource
Returns:
the language locale for the given resource in this index

getSearchRootsForScope

public java.util.List<java.lang.String> getSearchRootsForScope(CmsGallerySearchScope scope,
                                                               java.lang.String siteParam,
                                                               java.lang.String subSiteParam)
Gets the search roots to use for the given site/subsite parameters.

Parameters:
scope - the search scope
siteParam - the current site
subSiteParam - the current subsite
Returns:
the list of search roots for that option

searchGallery

public CmsGallerySearchResultList searchGallery(CmsObject cms,
                                                CmsGallerySearchParameters params)
                                         throws CmsSearchException
Performs a search on the gallery index.

Parameters:
cms - the current users OpenCms context
params - the parameters to use for the search
Returns:
the List of results found
Throws:
CmsSearchException - if something goes wrong

appendContainerTypeFilter

protected org.apache.lucene.search.BooleanFilter appendContainerTypeFilter(CmsObject cms,
                                                                           org.apache.lucene.search.BooleanFilter filter,
                                                                           java.util.List<java.lang.String> containers)
Appends a container type filter to the given filter clause that matches all given container types.

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.

Parameters:
cms - the current OpenCms search context
filter - the filter to extend
containers - the containers that will compose the filter
Returns:
the extended filter clause

appendIgnoreSearchExclude

protected org.apache.lucene.search.BooleanFilter appendIgnoreSearchExclude(org.apache.lucene.search.BooleanFilter filter,
                                                                           boolean ignoreSearchExclude)
Appends the ignore search exclude property filter.

Parameters:
filter - the filter to extend
ignoreSearchExclude - true if the search exclude property should be ignored
Returns:
the extended filter clause

appendLocaleFilter

protected org.apache.lucene.search.BooleanFilter appendLocaleFilter(CmsObject cms,
                                                                    org.apache.lucene.search.BooleanFilter filter,
                                                                    java.lang.String locale)
Appends the locale filter to the given filter clause that matches the given locale.

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.

Parameters:
cms - the current OpenCms search context
filter - the filter to extend
locale - the locale that will compose the filter
Returns:
the extended filter clause

appendPathFilter

protected org.apache.lucene.search.BooleanFilter appendPathFilter(CmsObject cms,
                                                                  org.apache.lucene.search.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.

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.

Overrides:
appendPathFilter in class CmsSearchIndex
Parameters:
cms - the current OpenCms search context
filter - the filter to extend
roots - the VFS root paths that will compose the filter
Returns:
the extended filter clause

excludeFromIndex

protected boolean excludeFromIndex(CmsObject cms,
                                   CmsResource resource)
Checks if the provided resource should be excluded from this search index.

Overrides:
excludeFromIndex in class CmsSearchIndex
Parameters:
cms - the OpenCms context used for building the search index
resource - the resource to index
Returns:
true if the resource should be excluded, false if it should be included in this index

getLocaleExtendedFields

protected java.util.List<java.lang.String> getLocaleExtendedFields(java.util.List<java.lang.String> fields,
                                                                   java.util.Locale locale)
Returns a list of locale extended field names.

Parameters:
fields - the field name to extend
locale - the locale to extend the field names with
Returns:
a list of locale extended field names

getResource

protected CmsResource getResource(CmsObject cms,
                                  I_CmsSearchDocument doc)
We are overriding getResource since the default implementation uses the path to read the resource, which doesn't work for resources in a different site.

Overrides:
getResource in class CmsSearchIndex
Parameters:
cms - the OpenCms user context to use for permission testing
doc - the search result document to check
Returns:
the referenced CmsResource or null if the user is not permitted
See Also:
CmsSearchIndex.getResource(org.opencms.file.CmsObject, org.opencms.search.I_CmsSearchDocument)