org.opencms.search.fields
Class CmsSearchField

java.lang.Object
  extended by org.opencms.search.fields.CmsSearchField
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CmsLuceneField, CmsSolrField

public class CmsSearchField
extends java.lang.Object
implements java.io.Serializable

A abstract implementation for a search field.

Since:
8.5.0
See Also:
Serialized Form

Field Summary
static float BOOST_DEFAULT
          Th default boost factor (1.0), used in case no boost has been set for a field.
static java.lang.String FIELD_CATEGORY
          Name of the field that contains the (optional) category of the document (hardcoded).
static java.lang.String FIELD_CONTENT
          Name of the field that usually contains the complete content of the document (optional).
static java.lang.String FIELD_CONTENT_BLOB
          Name of the field that contains the complete extracted content of the document as serialized object (hardcoded).
static java.lang.String FIELD_CONTENT_LOCALES
          Name of the field that contains the locale of the document.
static java.lang.String FIELD_DATE_CONTENT
          Name of the field that contains the document content date (hardcoded).
static java.lang.String FIELD_DATE_CREATED
          Name of the field that contains the document creation date (hardcoded).
static java.lang.String FIELD_DATE_CREATED_LOOKUP
          Name of the field that contains the document creation date for fast lookup (hardcoded).
static java.lang.String FIELD_DATE_EXPIRED
          The field name for the expiration date.
static java.lang.String FIELD_DATE_LASTMODIFIED
          Name of the field that contains the document last modification date (hardcoded).
static java.lang.String FIELD_DATE_LASTMODIFIED_LOOKUP
          Name of the field that contains the document last modification date for fast lookup (hardcoded).
static java.lang.String FIELD_DATE_LOOKUP_SUFFIX
          The lookup suffix for date fields.
static java.lang.String FIELD_DATE_RELEASED
          The field name for the release date.
static java.lang.String FIELD_DEPENDENCY_TYPE
          The dependency type.
static java.lang.String FIELD_DESCRIPTION
          Name of the field that usually contains the value of the "Description" property of the document (optional).
static java.lang.String FIELD_DYNAMIC_EXACT
          Name of the dynamic exact field.
static java.lang.String FIELD_DYNAMIC_PROPERTIES
          Name of the dynamic property field.
static java.lang.String FIELD_EXCERPT
          The name of the dynamic field that stores the shortened value of the content field in order to save performance.
static java.lang.String FIELD_ID
          Name of the field that contains the documents structure id.
static java.lang.String FIELD_KEYWORDS
          Name of the field that usually contains the value of the "Keywords" property of the document (optional).
static java.lang.String FIELD_LINK
          The field name for the link.
static java.lang.String FIELD_META
          Name of the field that usually combines all document "meta" information, that is the values of the "Title", "Keywords" and "Description" properties (optional).
static java.lang.String FIELD_PARENT_FOLDERS
          Name of the field that contains all VFS parent folders of a document (hardcoded).
static java.lang.String FIELD_PATH
          Name of the field that contains the document root path in the VFS (hardcoded).
static java.lang.String FIELD_PREFIX_DEPENDENCY
          The prefix used to store dependency fields.
static java.lang.String FIELD_PREFIX_DYNAMIC
          The prefix for dynamic fields.
static java.lang.String FIELD_PREFIX_TEXT
          The default text field prefix.
static java.lang.String FIELD_PRIORITY
          Name of the field that contains the (optional) document priority, which can be used to boost the document in the result list (hardcoded).
static java.lang.String FIELD_RESOURCE_LOCALES
          Name of the field that contains the resource locales of the document.
static java.lang.String FIELD_SCORE
          The name of the score field.
static java.lang.String FIELD_SEARCH_EXCLUDE
          Name of the field that contains the searched property value of 'search.exclude'.
static java.lang.String FIELD_SIZE
          Name of the field that usually contains file size.
static java.lang.String FIELD_SUFFIX
          Name of the field that contains the file name suffix of the resource.
static java.lang.String FIELD_TEXT
          Name of the field that contains the general text of a resource and also serves as prefix.
static java.lang.String FIELD_TITLE
          Name of the field that usually contains the value of the "Title" property of the document as a keyword used for sorting and also for retrieving the title text (optional).
static java.lang.String FIELD_TITLE_UNSTORED
          Name of the field that usually contains the value of the "Title" property of the document in an analyzed form used for searching in the title (optional).
static java.lang.String FIELD_TYPE
          Name of the field that contains the type of the document.
 
Constructor Summary
CmsSearchField()
          Creates a new search field.
CmsSearchField(java.lang.String name, java.lang.String defaultValue, float boost)
          Creates a new search field.
 
Method Summary
 void addMapping(I_CmsSearchFieldMapping mapping)
          Adds a new field mapping to the internal list of mappings.
 boolean equals(java.lang.Object obj)
          Two fields are equal if the name of the Lucene field is equal.
 float getBoost()
          Returns the boost factor of this field.
 java.lang.String getDefaultValue()
          Returns the default value to use if no content for this field was collected.
 java.lang.String getIndexed()
          Returns the String value state of this field if it is indexed (and possibly tokenized) in the index.
 java.util.List<I_CmsSearchFieldMapping> getMappings()
          Returns the mappings for this field.
 java.lang.String getName()
          Returns the name of this field in the Lucene search index.
 int hashCode()
          The hash code for a field is based only on the field name.
 boolean isIndexed()
          Returns the indexed.
 boolean isInExcerpt()
          Returns true if this fields content is used in the search result excerpt.
 boolean isStored()
          Returns true if the content of this field is stored in the Lucene index.
 void setBoost(float boost)
          Sets the boost factor for this field.
 void setBoost(java.lang.String boostAsString)
          Sets the boost factor for this field from a String value.
 void setDefaultValue(java.lang.String defaultValue)
          Sets the default value to use if no content for this field was collected.
 void setIndexed(boolean indexed)
          Controls if the content of this field is indexed (and possibly tokenized) in the Lucene index.
 void setInExcerpt(boolean excerpt)
          Controls if this fields content is used in the search result excerpt.
 void setName(java.lang.String fieldName)
          Sets the name of this field in the Lucene search index.
 void setStored(boolean stored)
          Controls if the content of this field is stored in the Lucene index.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOST_DEFAULT

public static final float BOOST_DEFAULT
Th default boost factor (1.0), used in case no boost has been set for a field.

See Also:
Constant Field Values

FIELD_CATEGORY

public static final java.lang.String FIELD_CATEGORY
Name of the field that contains the (optional) category of the document (hardcoded).

See Also:
Constant Field Values

FIELD_CONTENT

public static final java.lang.String FIELD_CONTENT
Name of the field that usually contains the complete content of the document (optional).

See Also:
Constant Field Values

FIELD_CONTENT_BLOB

public static final java.lang.String FIELD_CONTENT_BLOB
Name of the field that contains the complete extracted content of the document as serialized object (hardcoded).

See Also:
Constant Field Values

FIELD_CONTENT_LOCALES

public static final java.lang.String FIELD_CONTENT_LOCALES
Name of the field that contains the locale of the document.

See Also:
Constant Field Values

FIELD_DATE_CONTENT

public static final java.lang.String FIELD_DATE_CONTENT
Name of the field that contains the document content date (hardcoded).

See Also:
Constant Field Values

FIELD_DATE_CREATED

public static final java.lang.String FIELD_DATE_CREATED
Name of the field that contains the document creation date (hardcoded).

See Also:
Constant Field Values

FIELD_DATE_CREATED_LOOKUP

public static final java.lang.String FIELD_DATE_CREATED_LOOKUP
Name of the field that contains the document creation date for fast lookup (hardcoded).

See Also:
Constant Field Values

FIELD_DATE_EXPIRED

public static final java.lang.String FIELD_DATE_EXPIRED
The field name for the expiration date.

See Also:
Constant Field Values

FIELD_DATE_LASTMODIFIED

public static final java.lang.String FIELD_DATE_LASTMODIFIED
Name of the field that contains the document last modification date (hardcoded).

See Also:
Constant Field Values

FIELD_DATE_LASTMODIFIED_LOOKUP

public static final java.lang.String FIELD_DATE_LASTMODIFIED_LOOKUP
Name of the field that contains the document last modification date for fast lookup (hardcoded).

See Also:
Constant Field Values

FIELD_DATE_LOOKUP_SUFFIX

public static final java.lang.String FIELD_DATE_LOOKUP_SUFFIX
The lookup suffix for date fields.

See Also:
Constant Field Values

FIELD_DATE_RELEASED

public static final java.lang.String FIELD_DATE_RELEASED
The field name for the release date.

See Also:
Constant Field Values

FIELD_DEPENDENCY_TYPE

public static final java.lang.String FIELD_DEPENDENCY_TYPE
The dependency type.

See Also:
Constant Field Values

FIELD_DESCRIPTION

public static final java.lang.String FIELD_DESCRIPTION
Name of the field that usually contains the value of the "Description" property of the document (optional).

See Also:
Constant Field Values

FIELD_DYNAMIC_EXACT

public static final java.lang.String FIELD_DYNAMIC_EXACT
Name of the dynamic exact field.

See Also:
Constant Field Values

FIELD_DYNAMIC_PROPERTIES

public static final java.lang.String FIELD_DYNAMIC_PROPERTIES
Name of the dynamic property field.

See Also:
Constant Field Values

FIELD_EXCERPT

public static final java.lang.String FIELD_EXCERPT
The name of the dynamic field that stores the shortened value of the content field in order to save performance.

See Also:
Constant Field Values

FIELD_ID

public static final java.lang.String FIELD_ID
Name of the field that contains the documents structure id.

See Also:
Constant Field Values

FIELD_KEYWORDS

public static final java.lang.String FIELD_KEYWORDS
Name of the field that usually contains the value of the "Keywords" property of the document (optional).

See Also:
Constant Field Values

FIELD_LINK

public static final java.lang.String FIELD_LINK
The field name for the link.

See Also:
Constant Field Values

FIELD_META

public static final java.lang.String FIELD_META
Name of the field that usually combines all document "meta" information, that is the values of the "Title", "Keywords" and "Description" properties (optional).

See Also:
Constant Field Values

FIELD_PARENT_FOLDERS

public static final java.lang.String FIELD_PARENT_FOLDERS
Name of the field that contains all VFS parent folders of a document (hardcoded).

See Also:
Constant Field Values

FIELD_PATH

public static final java.lang.String FIELD_PATH
Name of the field that contains the document root path in the VFS (hardcoded).

See Also:
Constant Field Values

FIELD_PREFIX_DEPENDENCY

public static final java.lang.String FIELD_PREFIX_DEPENDENCY
The prefix used to store dependency fields.

See Also:
Constant Field Values

FIELD_PREFIX_DYNAMIC

public static final java.lang.String FIELD_PREFIX_DYNAMIC
The prefix for dynamic fields.

See Also:
Constant Field Values

FIELD_PREFIX_TEXT

public static final java.lang.String FIELD_PREFIX_TEXT
The default text field prefix.

See Also:
Constant Field Values

FIELD_PRIORITY

public static final java.lang.String FIELD_PRIORITY
Name of the field that contains the (optional) document priority, which can be used to boost the document in the result list (hardcoded).

See Also:
Constant Field Values

FIELD_RESOURCE_LOCALES

public static final java.lang.String FIELD_RESOURCE_LOCALES
Name of the field that contains the resource locales of the document.

See Also:
Constant Field Values

FIELD_SCORE

public static final java.lang.String FIELD_SCORE
The name of the score field.

See Also:
Constant Field Values

FIELD_SEARCH_EXCLUDE

public static final java.lang.String FIELD_SEARCH_EXCLUDE
Name of the field that contains the searched property value of 'search.exclude'.

See Also:
Constant Field Values

FIELD_SIZE

public static final java.lang.String FIELD_SIZE
Name of the field that usually contains file size.

See Also:
Constant Field Values

FIELD_SUFFIX

public static final java.lang.String FIELD_SUFFIX
Name of the field that contains the file name suffix of the resource.

See Also:
Constant Field Values

FIELD_TEXT

public static final java.lang.String FIELD_TEXT
Name of the field that contains the general text of a resource and also serves as prefix.

See Also:
Constant Field Values

FIELD_TITLE

public static final java.lang.String FIELD_TITLE
Name of the field that usually contains the value of the "Title" property of the document as a keyword used for sorting and also for retrieving the title text (optional). Please note: This field should NOT be used for searching. Use FIELD_TITLE_UNSTORED instead.

See Also:
Constant Field Values

FIELD_TITLE_UNSTORED

public static final java.lang.String FIELD_TITLE_UNSTORED
Name of the field that usually contains the value of the "Title" property of the document in an analyzed form used for searching in the title (optional).

See Also:
Constant Field Values

FIELD_TYPE

public static final java.lang.String FIELD_TYPE
Name of the field that contains the type of the document.

See Also:
Constant Field Values
Constructor Detail

CmsSearchField

public CmsSearchField()
Creates a new search field.


CmsSearchField

public CmsSearchField(java.lang.String name,
                      java.lang.String defaultValue,
                      float boost)
Creates a new search field.

Parameters:
name - the name of the field, see setName(String)
defaultValue - the default value to use, see setDefaultValue(String)
boost - the boost factor, see setBoost(float)
Method Detail

addMapping

public void addMapping(I_CmsSearchFieldMapping mapping)
Adds a new field mapping to the internal list of mappings.

Parameters:
mapping - the mapping to add

equals

public boolean equals(java.lang.Object obj)
Two fields are equal if the name of the Lucene field is equal.

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

getBoost

public float getBoost()
Returns the boost factor of this field.

The boost factor is a Lucene function that controls the "importance" of a field in the search result ranking. The default is 1.0. A lower boost factor will make the field less important for the result ranking, a higher value will make it more important.

Returns:
the boost factor of this field

getDefaultValue

public java.lang.String getDefaultValue()
Returns the default value to use if no content for this field was collected.

In case no default is configured, null is returned.

Returns:
the default value to use if no content for this field was collected

getIndexed

public java.lang.String getIndexed()
Returns the String value state of this field if it is indexed (and possibly tokenized) in the index.

IMPORTANT: Not supported by Solr

Returns:
the String value state of this field if it is indexed (and possibly tokenized) in the index

getMappings

public java.util.List<I_CmsSearchFieldMapping> getMappings()
Returns the mappings for this field.

Returns:
the mappings for this field

getName

public java.lang.String getName()
Returns the name of this field in the Lucene search index.

Returns:
the name of this field in the Lucene search index

hashCode

public int hashCode()
The hash code for a field is based only on the field name.

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

isIndexed

public boolean isIndexed()
Returns the indexed.

Returns:
the indexed

isInExcerpt

public boolean isInExcerpt()
Returns true if this fields content is used in the search result excerpt.

Returns:
true if this fields content is used in the search result excerpt
See Also:
isStored()

isStored

public boolean isStored()
Returns true if the content of this field is stored in the Lucene index.

Please refer to the Lucene documentation about Field.Store for the concept behind stored and unstored fields.

Returns:
true if the content of this field is stored in the Lucene index

setBoost

public void setBoost(float boost)
Sets the boost factor for this field.

The boost factor is a Lucene function that controls the "importance" of a field in the search result ranking. The default is 1.0. A lower boost factor will make the field less important for the result ranking, a higher value will make it more important.

Use with caution: You should only use this if you fully understand the concept behind boost factors. Otherwise it is likely that your result rankings will be worse then with the default values.

Parameters:
boost - the boost factor to set

setBoost

public void setBoost(java.lang.String boostAsString)
Sets the boost factor for this field from a String value.

Parameters:
boostAsString - the boost factor to set
See Also:
setBoost(float)

setDefaultValue

public void setDefaultValue(java.lang.String defaultValue)
Sets the default value to use if no content for this field was collected.

Parameters:
defaultValue - the default value to set

setIndexed

public void setIndexed(boolean indexed)
Controls if the content of this field is indexed (and possibly tokenized) in the Lucene index.

Parameters:
indexed - the indexed to set

setInExcerpt

public void setInExcerpt(boolean excerpt)
Controls if this fields content is used in the search result excerpt.

Parameters:
excerpt - if true, then this fields content is used in the search excerpt

setName

public void setName(java.lang.String fieldName)
Sets the name of this field in the Lucene search index.

Parameters:
fieldName - the name to set

setStored

public void setStored(boolean stored)
Controls if the content of this field is stored in the Lucene index.

Please refer to the Lucene documentation about Field.Store for the concept behind stored and unstored fields.

Parameters:
stored - if true, then the field content is stored

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()