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_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
BACKUP_REINDEXING, CONTENT_SELECTOR, DATES, DOC_META_FIELDS, EXCERPT, EXTRACT_CONTENT, LUCENE_AUTO_COMMIT, LUCENE_MAX_MERGE_DOCS, LUCENE_MERGE_FACTOR, LUCENE_RAM_BUFFER_SIZE_MB, LUCENE_USE_COMPOUND_FILE, LUCENE_VERSION, m_requireViewPermission, m_sources, 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, 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 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.
 org.apache.lucene.document.Document 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.
 java.util.List<java.lang.String> getSearchRootsForScope(CmsGallerySearchScope scope, 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, createIndexBackup, equals, extendPathFilter, getAnalyzer, getConfiguration, getDateRangeSpan, getDocument, getDocument, getFieldConfiguration, getFieldConfigurationName, getIndexWriter, getLocale, getLocaleString, getMaxHits, getMultiTermQueryFilter, getMultiTermQueryFilter, getMultiTermQueryFilter, getName, getPath, getPriority, getProject, getRebuildMode, getSearcher, getSourceNames, getSources, getTermQueryFilter, hashCode, hasReadPermission, indexSearcherClose, indexSearcherClose, indexSearcherOpen, indexSearcherUpdate, indexWriterCreate, indexWriterUnlock, initConfiguration, initialize, isBackupReindexing, isCheckingPermissions, isCheckingTimeRange, isCreatingExcerpt, isEnabled, isExtractingContent, isInTimeRange, isRequireViewPermission, isUpdatedIncremental, prepareSortScoring, removeIndexBackup, removeSourceName, search, setAnalyzer, setEnabled, setFieldConfiguration, setFieldConfigurationName, setLocale, setLocaleString, setMaxHits, setName, setProject, setProjectName, setRebuildMode, setRequireViewPermission, shutDown, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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 org.apache.lucene.document.Document 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 subSiteParam)
Gets the search roots to use for the given site/subsite parameters.

Parameters:
scope - the search scope
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

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.

With the introduction of the gallery search index in OpenCms 8, the meaning of the VFS property search.exclude that controls if a resource is included in a search index has been extended.

The following uses cases can be covered with the property:

Case A: Exclude from all indexes
Applies at least to ADE resource type copy templates.
Set search.exclude=all
Case B: Include in all indexes
Applies to most resources e.g. news articles etc.
Set search.exclude=false - or anything else but all|true|gallery. This is also the default in case the property is not set at all.
Case D: Include in gallery index, but exclude in standard index
Applies to content like articles that are displayed only in container pages, also applies to "list generating" resource types like those that contain settings for a collector.
Set search.exclude=true - This is the behavior before OpenCms v8.
Case C: Exclude from gallery index, but include in standard index
Use case so far unknown, but implemented anyway.
Set search.exclude=gallery.

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