org.opencms.search.fields
Class CmsSearchFieldConfiguration

java.lang.Object
  extended by org.opencms.search.fields.CmsSearchFieldConfiguration
All Implemented Interfaces:
java.lang.Comparable<CmsSearchFieldConfiguration>

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

Describes a configuration of fields that are used in building a search index.

Since:
7.0.0
Version:
$Revision: 1.14 $
Author:
Alexander Kandzior

Field Summary
static CmsSearchFieldConfiguration DEFAULT_STANDARD
          The default for the standard search configuration.
static java.lang.String SEARCH_PRIORITY_HIGH_VALUE
          Value for "high" search priority.
static java.lang.String SEARCH_PRIORITY_LOW_VALUE
          Value for "low" search priority.
static java.lang.String SEARCH_PRIORITY_MAX_VALUE
          Value for "maximum" search priority.
static java.lang.String SEARCH_PRIORITY_NORMAL_VALUE
          Value for "normal" search priority.
static java.lang.String STR_STANDARD
          The name for the standard field configuration.
static java.lang.String STR_STANDARD_DESCRIPTION
          The description for the standard field configuration.
static java.lang.String VFS_DOCUMENT_KEY_PREFIX
          The VFS prefix for document keys.
 
Constructor Summary
CmsSearchFieldConfiguration()
          Creates a new, empty field configuration.
 
Method Summary
 void addField(CmsSearchField field)
          Adds a field to this search field configuration.
 int compareTo(CmsSearchFieldConfiguration obj)
           
 org.apache.lucene.document.Document createDocument(CmsObject cms, CmsResource resource, CmsSearchIndex index, I_CmsExtractionResult content)
          Creates the Lucene Document with this field configuration for the provided VFS resource, search index and content.
 boolean equals(java.lang.Object obj)
           
 org.apache.lucene.analysis.Analyzer getAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
          Returns an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration.
protected  org.apache.lucene.analysis.Analyzer getAnalyzerForDefaultFields(org.apache.lucene.analysis.Analyzer analyzer)
          Returns an analyzer that wraps the given base analyzer with special analyzers required for the hard coded document fields.
 java.lang.String getDescription()
          Returns the description of this field configuration.
 java.util.List<java.lang.String> getExcerptFieldNames()
          Returns a list of all field names (Strings) that are used in generating the search excerpt.
 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.
 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 setDescription(java.lang.String description)
          Sets the description of this field configuration.
 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

DEFAULT_STANDARD

public static final CmsSearchFieldConfiguration DEFAULT_STANDARD
The default for the standard search configuration.

This defines the default that is used in case no "standard" field configuration is defined in opencms-search.xml.


SEARCH_PRIORITY_HIGH_VALUE

public static final java.lang.String SEARCH_PRIORITY_HIGH_VALUE
Value for "high" search priority.

See Also:
Constant Field Values

SEARCH_PRIORITY_LOW_VALUE

public static final java.lang.String SEARCH_PRIORITY_LOW_VALUE
Value for "low" search priority.

See Also:
Constant Field Values

SEARCH_PRIORITY_MAX_VALUE

public static final java.lang.String SEARCH_PRIORITY_MAX_VALUE
Value for "maximum" search priority.

See Also:
Constant Field Values

SEARCH_PRIORITY_NORMAL_VALUE

public static final java.lang.String SEARCH_PRIORITY_NORMAL_VALUE
Value for "normal" search priority.

See Also:
Constant Field Values

STR_STANDARD

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

See Also:
Constant Field Values

STR_STANDARD_DESCRIPTION

public static final java.lang.String STR_STANDARD_DESCRIPTION
The description for the standard field configuration.

See Also:
Constant Field Values

VFS_DOCUMENT_KEY_PREFIX

public static final java.lang.String VFS_DOCUMENT_KEY_PREFIX
The VFS prefix for document keys.

See Also:
Constant Field Values
Constructor Detail

CmsSearchFieldConfiguration

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

Method Detail

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

compareTo

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

createDocument

public org.apache.lucene.document.Document createDocument(CmsObject cms,
                                                          CmsResource resource,
                                                          CmsSearchIndex index,
                                                          I_CmsExtractionResult content)
                                                   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
content - the plain text content extracted from the document
Returns:
the Lucene 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)

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
Returns an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration.

Parameters:
analyzer - the base analyzer to wrap
Returns:
an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration

getDescription

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

Returns:
the description of this field configuration

getExcerptFieldNames

public java.util.List<java.lang.String> getExcerptFieldNames()
Returns a list of all field names (Strings) that are used in generating the search excerpt.

Returns:
a list of all field names (Strings) that are used in generating the search excerpt

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

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()

setDescription

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

Parameters:
description - the description to set

setName

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

Parameters:
name - the name to set

getAnalyzerForDefaultFields

protected org.apache.lucene.analysis.Analyzer getAnalyzerForDefaultFields(org.apache.lucene.analysis.Analyzer analyzer)
Returns an analyzer that wraps the given base analyzer with special analyzers required for the hard coded document fields.

Parameters:
analyzer - the base analyzer to wrap
Returns:
an analyzer that wraps the given base analyzer for the hard coded document fields
See Also:
getAnalyzer(Analyzer)