org.opencms.search.fields
Class CmsSearchFieldConfiguration

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

public class CmsSearchFieldConfiguration
extends java.lang.Object
implements java.lang.Comparable<CmsSearchFieldConfiguration>

Abstract implementation for OpenCms search field configurations.

Since:
8.5.0

Field Summary
static java.lang.String STR_STANDARD
          The name for the standard field configuration.
 
Constructor Summary
CmsSearchFieldConfiguration()
          Creates a new, empty field configuration.
 
Method Summary
 void addField(CmsSearchField field)
          Adds a field to this search field configuration.
 void addFields(java.util.Collection<CmsSearchField> fields)
          Adds fields.
protected  I_CmsSearchDocument appendCategories(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by resource category information based on properties.
protected  I_CmsSearchDocument appendContentBlob(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by a field that contains the extracted content blob.
protected  I_CmsSearchDocument appendDates(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by fields for date of creation, content and last modification.
protected  I_CmsSearchDocument appendFieldMapping(I_CmsSearchDocument document, CmsSearchField field, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by the mappings for the given field.
protected  I_CmsSearchDocument appendFieldMappings(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by the configured field mappings.
protected  I_CmsSearchDocument appendFileSize(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by the "size" field.
protected  I_CmsSearchDocument appendLocales(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by the "res_locales" field.
protected  I_CmsSearchDocument appendPath(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by fields for VFS path lookup.
protected  I_CmsSearchDocument appendProperties(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Appends all direct properties, that are not empty or white space only to the document.
protected  I_CmsSearchDocument appendType(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document by a field that contains the resource type name.
 int compareTo(CmsSearchFieldConfiguration obj)
           
 I_CmsSearchDocument createDocument(CmsObject cms, CmsResource resource, CmsSearchIndex index, I_CmsExtractionResult extraction)
          Creates the Lucene Document with this field configuration for the provided VFS resource, search index and content.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getDescription()
          Returns the description of this field configuration.
 CmsSearchField getField(java.lang.String name)
          Returns the configured CmsSearchField instance with the given name.
 java.util.List<java.lang.String> getFieldNames()
          Returns the list of configured field names (Strings).
 java.util.List<CmsSearchField> getFields()
          Returns the list of configured CmsSearchField instances.
 CmsSearchIndex getIndex()
          Returns the index.
static java.lang.String getLocaleExtendedName(java.lang.String lookup, java.util.Locale locale)
          Returns the locale extended name for the given lookup String.
static java.lang.String getLocaleExtendedName(java.lang.String lookup, java.lang.String locale)
          Returns the locale extended name for the given lookup String.
 java.lang.String getName()
          Returns the name of this field configuration.
static java.lang.String getParentFolderTokens(java.lang.String rootPath)
          Creates a space separated list of all parent folders of the given root path.
 int hashCode()
           
 void init()
          Initializes this field configuration.
protected  I_CmsSearchDocument setBoost(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Extends the given document with a boost factor.
 void setDescription(java.lang.String description)
          Sets the description of this field configuration.
 void setIndex(CmsSearchIndex index)
          Sets the index.
 void setName(java.lang.String name)
          Sets the name of this field configuration.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STR_STANDARD

public static final java.lang.String STR_STANDARD
The name for the standard field configuration.

See Also:
Constant Field Values
Constructor Detail

CmsSearchFieldConfiguration

public CmsSearchFieldConfiguration()
Creates a new, empty field configuration.

Method Detail

getLocaleExtendedName

public static final java.lang.String getLocaleExtendedName(java.lang.String lookup,
                                                           java.util.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 java.lang.String getLocaleExtendedName(java.lang.String lookup,
                                                           java.lang.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 java.lang.String getParentFolderTokens(java.lang.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

addField

public void addField(CmsSearchField field)
Adds a field to this search field configuration.

Parameters:
field - the field to add

addFields

public void addFields(java.util.Collection<CmsSearchField> fields)
Adds fields.

Parameters:
fields - the fields to add

compareTo

public int compareTo(CmsSearchFieldConfiguration obj)
Specified by:
compareTo in interface java.lang.Comparable<CmsSearchFieldConfiguration>
See Also:
Comparable.compareTo(java.lang.Object)

createDocument

public I_CmsSearchDocument createDocument(CmsObject cms,
                                          CmsResource resource,
                                          CmsSearchIndex index,
                                          I_CmsExtractionResult extraction)
                                   throws CmsException
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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getDescription

public java.lang.String getDescription()
Returns the description of this field configuration.

Returns:
the description of this field configuration

getField

public CmsSearchField getField(java.lang.String name)
Returns the configured CmsSearchField instance with the given name.

Parameters:
name - the search field name to look up
Returns:
the configured CmsSearchField instance with the given name

getFieldNames

public java.util.List<java.lang.String> getFieldNames()
Returns the list of configured field names (Strings).

Returns:
the list of configured field names (Strings)

getFields

public java.util.List<CmsSearchField> getFields()
Returns the list of configured CmsSearchField instances.

Returns:
the list of configured CmsSearchField instances

getIndex

public CmsSearchIndex getIndex()
Returns the index.

Returns:
the index

getName

public java.lang.String getName()
Returns the name of this field configuration.

Returns:
the name of this field configuration

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

init

public void init()
Initializes this field configuration.


setDescription

public void setDescription(java.lang.String description)
Sets the description of this field configuration.

Parameters:
description - the description to set

setIndex

public void setIndex(CmsSearchIndex index)
Sets the index.

Parameters:
index - the index to set

setName

public void setName(java.lang.String name)
Sets the name of this field configuration.

Parameters:
name - the name to set

appendCategories

protected I_CmsSearchDocument appendCategories(I_CmsSearchDocument document,
                                               CmsObject cms,
                                               CmsResource resource,
                                               I_CmsExtractionResult extractionResult,
                                               java.util.List<CmsProperty> properties,
                                               java.util.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,
                                                java.util.List<CmsProperty> properties,
                                                java.util.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,
                                          java.util.List<CmsProperty> properties,
                                          java.util.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,
                                                 java.util.List<CmsProperty> properties,
                                                 java.util.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,
                                                  java.util.List<CmsProperty> properties,
                                                  java.util.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,
                                             java.util.List<CmsProperty> properties,
                                             java.util.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,
                                            java.util.List<CmsProperty> properties,
                                            java.util.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,
                                         java.util.List<CmsProperty> properties,
                                         java.util.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,
                                               java.util.List<CmsProperty> properties,
                                               java.util.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,
                                         java.util.List<CmsProperty> properties,
                                         java.util.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

setBoost

protected I_CmsSearchDocument setBoost(I_CmsSearchDocument document,
                                       CmsObject cms,
                                       CmsResource resource,
                                       I_CmsExtractionResult extractionResult,
                                       java.util.List<CmsProperty> properties,
                                       java.util.List<CmsProperty> propertiesSearched)
Extends the given document with a boost factor.

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 boost factor