Class CmsSearchFieldConfiguration

java.lang.Object
org.opencms.search.fields.A_CmsSearchFieldConfiguration
org.opencms.search.fields.CmsSearchFieldConfiguration
All Implemented Interfaces:
Serializable, Comparable<I_CmsSearchFieldConfiguration>, I_CmsSearchFieldConfiguration
Direct Known Subclasses:
CmsLuceneFieldConfiguration, CmsSolrFieldConfiguration

Abstract implementation for OpenCms search field configurations.

Since:
8.5.0
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getLocaleExtendedName

      public static final String getLocaleExtendedName(String lookup, Locale locale)
      Returns the locale extended name for the given lookup String.

      Parameters:
      lookup - the lookup String
      locale - the locale
      Returns:
      the locale extended name for the given lookup String
    • getLocaleExtendedName

      public static final String getLocaleExtendedName(String lookup, String locale)
      Returns the locale extended name for the given lookup String.

      Parameters:
      lookup - the lookup String
      locale - the locale
      Returns:
      the locale extended name for the given lookup String
    • getParentFolderTokens

      public static String getParentFolderTokens(String rootPath)
      Creates a space separated list of all parent folders of the given root path.

      Parameters:
      rootPath - the root path to get the parent folder list for
      Returns:
      a space separated list of all parent folders of the given root path
    • addUninvertingMappings

      public void addUninvertingMappings(Map<String,org.apache.solr.uninverting.UninvertingReader.Type> uninvertingMap)
      To allow sorting on a field the field must be added to the map given to UninvertingReader.wrap(org.apache.lucene.index.DirectoryReader, Map). The method adds the configured fields.
      Specified by:
      addUninvertingMappings in interface I_CmsSearchFieldConfiguration
      Overrides:
      addUninvertingMappings in class A_CmsSearchFieldConfiguration
      Parameters:
      uninvertingMap - the map to which the fields are added.
      See Also:
    • createDocument

      Creates the Lucene Document with this field configuration for the provided VFS resource, search index and content.

      This triggers the indexing process for the given VFS resource according to the configuration of the provided index.

      The provided index resource contains the basic contents to index. The provided search index contains the configuration what to index, such as the locale and possible special field mappings.

      Parameters:
      cms - the OpenCms user context used to access the OpenCms VFS
      resource - the resource to create the Lucene document from
      index - the search index to create the Document for
      extraction - the plain text content extracted from the document
      Returns:
      the Search Document for the given VFS resource and the given search index
      Throws:
      CmsException - if something goes wrong
    • getIndex

      Returns the index.

      Returns:
      the index
    • setIndex

      public void setIndex(CmsSearchIndex index)
      Sets the index.

      Parameters:
      index - the index to set
    • appendAdditionalValuesToDcoument

      protected I_CmsSearchDocument appendAdditionalValuesToDcoument(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Overriding this method allows to append some 'extra' values/fields to a document without overriding the createDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.I_CmsSearchIndex, org.opencms.search.extractors.I_CmsExtractionResult) method itself.

      The method createDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.I_CmsSearchIndex, org.opencms.search.extractors.I_CmsExtractionResult) reads all properties of the current resource which is an expensive operation. In order to avoid reading those properties twice, this method has been introduced.

      Compared with all the other appender methods the name of this method is generic.

      In this default implementation the document is returned unchanged.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extraction - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by resource category information
    • appendCategories

      protected I_CmsSearchDocument appendCategories(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) throws CmsException
      Extends the given document by resource category information based on properties.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by resource category information
      Throws:
      CmsException - if something goes wrong
    • appendContentBlob

      protected I_CmsSearchDocument appendContentBlob(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by a field that contains the extracted content blob.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by a field that contains the extracted content blob
    • appendDates

      protected I_CmsSearchDocument appendDates(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by fields for date of creation, content and last modification.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by fields for date of creation, content and last modification
    • appendFieldMapping

      protected I_CmsSearchDocument appendFieldMapping(I_CmsSearchDocument document, CmsSearchField field, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by the mappings for the given field.

      Parameters:
      document - the document to extend
      field - the field to create the mappings for
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by the mappings for the given field
    • appendFieldMappings

      protected I_CmsSearchDocument appendFieldMappings(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by the configured field mappings.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by the configured field mappings
    • appendFileSize

      protected I_CmsSearchDocument appendFileSize(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by the "size" field.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by the resource locales
    • appendLocales

      protected I_CmsSearchDocument appendLocales(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by the "res_locales" field.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extraction - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by the resource locales
    • appendPath

      protected I_CmsSearchDocument appendPath(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Extends the given document by fields for VFS path lookup.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by fields for VFS path lookup
    • appendProperties

      protected I_CmsSearchDocument appendProperties(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched)
      Appends all direct properties, that are not empty or white space only to the document.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extraction - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by resource category information
    • appendType

      protected I_CmsSearchDocument appendType(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) throws CmsLoaderException
      Extends the given document by a field that contains the resource type name.

      Parameters:
      document - the document to extend
      cms - the OpenCms context used for building the search index
      resource - the resource that is indexed
      extractionResult - the plain text extraction result from the resource
      properties - the list of all properties directly attached to the resource (not searched)
      propertiesSearched - the list of all searched properties of the resource
      Returns:
      the document extended by a field that contains the resource type name
      Throws:
      CmsLoaderException - in case of errors identifying the resource type name