org.opencms.search.fields
Class CmsLuceneField

java.lang.Object
  extended by org.opencms.search.fields.CmsSearchField
      extended by org.opencms.search.fields.CmsLuceneField
All Implemented Interfaces:
java.io.Serializable

public class CmsLuceneField
extends CmsSearchField

An individual field configuration in a Lucene search index.

Since:
7.0.0
See Also:
Serialized Form

Field Summary
static java.lang.String IGNORE_DISPLAY_NAME
          Value of m_displayName if field should not be displayed.
static java.lang.String STR_COMPRESS
          Constant for the "compress" index setting.
static java.lang.String STR_NO
          Constant for the "no" index setting.
static java.lang.String STR_TOKENIZED
          Constant for the "tokenized" index setting.
static java.lang.String STR_UN_TOKENIZED
          Constant for the "untokenized" index setting.
static java.lang.String STR_YES
          Constant for the "yes" index setting.
 
Fields inherited from class org.opencms.search.fields.CmsSearchField
BOOST_DEFAULT, FIELD_CATEGORY, FIELD_CONTENT, FIELD_CONTENT_BLOB, FIELD_CONTENT_LOCALES, FIELD_DATE_CONTENT, FIELD_DATE_CREATED, FIELD_DATE_CREATED_LOOKUP, FIELD_DATE_EXPIRED, FIELD_DATE_LASTMODIFIED, FIELD_DATE_LASTMODIFIED_LOOKUP, FIELD_DATE_LOOKUP_SUFFIX, FIELD_DATE_RELEASED, FIELD_DEPENDENCY_TYPE, FIELD_DESCRIPTION, FIELD_DYNAMIC_EXACT, FIELD_DYNAMIC_PROPERTIES, FIELD_EXCERPT, FIELD_ID, FIELD_KEYWORDS, FIELD_LINK, FIELD_META, FIELD_PARENT_FOLDERS, FIELD_PATH, FIELD_PREFIX_DEPENDENCY, FIELD_PREFIX_DYNAMIC, FIELD_PREFIX_TEXT, FIELD_PRIORITY, FIELD_RESOURCE_LOCALES, FIELD_SCORE, FIELD_SEARCH_EXCLUDE, FIELD_SIZE, FIELD_SUFFIX, FIELD_TEXT, FIELD_TITLE, FIELD_TITLE_UNSTORED, FIELD_TYPE
 
Constructor Summary
CmsLuceneField()
          Creates a new search field configuration.
CmsLuceneField(java.lang.String name, java.lang.String displayName, boolean isStored, boolean isIndexed)
          Creates a new search field configuration.
CmsLuceneField(java.lang.String name, java.lang.String displayName, boolean isStored, boolean isCompressed, boolean isIndexed, boolean isTokenized, boolean isInExcerpt, org.apache.lucene.analysis.Analyzer analyzer, float boost, java.lang.String defaultValue)
          Creates a new search field configuration.
CmsLuceneField(java.lang.String name, java.lang.String displayName, boolean isStored, boolean isIndexed, boolean isTokenized, boolean isInExcerpt, float boost, java.lang.String defaultValue)
          Creates a new search field configuration.
 
Method Summary
 org.apache.lucene.document.Field createField(java.lang.String content)
          Creates a field from the configuration and the provided content.
 org.apache.lucene.document.Field createField(java.lang.String name, java.lang.String content)
          Creates a field with the given name from the configuration and the provided content.
 org.apache.lucene.analysis.Analyzer getAnalyzer()
          Returns the analyzer used for this field.
 java.lang.String getBoostDisplay()
          Returns the boost factor of this field as String value for display use.
 java.lang.String getDisplayName()
          Returns the display name of the field.
 java.lang.String getDisplayNameForConfiguration()
          Returns the displayNameForConfiguration.
 java.lang.String getIndexed()
          Returns the String value state of this field if it is indexed (and possibly tokenized) in the Lucene index.
 java.lang.String getType()
          Returns the type.
 boolean isCompressed()
          Returns true if the content of this field is compressed.
 boolean isDisplayed()
          Returns true if the field should be displayed.
 boolean isInExcerptAndStored()
          Returns true if this fields content is used in the search result excerpt.
 boolean isTokenized()
          Returns true if the content of this field is tokenized in the Lucene index.
 boolean isTokenizedAndIndexed()
          Returns true if the content of this field is tokenized in the Lucene index.
 void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
          Sets the analyzer used for this field.
 void setAnalyzer(java.lang.String analyzerName)
          Sets the analyzer used for this field.
 void setBoostDisplay(java.lang.String boost)
          Sets the boost factor of this field (only for display use).
 void setCompressed(boolean compressed)
          Controls if this field value will be stored compressed or not.
 void setDisplayed(boolean displayed)
          Controls if the field is displayed or not.
 void setDisplayName(java.lang.String displayName)
          Sets the display name.
 void setDisplayNameForConfiguration(java.lang.String displayNameForConfiguration)
          Sets the displayNameForConfiguration.
 void setIndexed(java.lang.String indexed)
          Controls if the content of this field is indexed (and possibly tokenized) in the Lucene index from a String parameter.
 void setInExcerpt(java.lang.String excerpt)
          Controls if this fields content is used in the search result excerpt.
 void setStored(java.lang.String stored)
          Controls if the content of this field is stored in the Lucene index from a String parameter.
 void setTokenized(boolean tokenized)
          Controls if the content of this field is tokenized in the Lucene index.
 void setType(java.lang.String type)
          Sets the type.
 
Methods inherited from class org.opencms.search.fields.CmsSearchField
addMapping, equals, getBoost, getDefaultValue, getMappings, getName, hashCode, isIndexed, isInExcerpt, isStored, setBoost, setBoost, setDefaultValue, setIndexed, setInExcerpt, setName, setStored, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IGNORE_DISPLAY_NAME

public static final java.lang.String IGNORE_DISPLAY_NAME
Value of m_displayName if field should not be displayed.

See Also:
Constant Field Values

STR_COMPRESS

public static final java.lang.String STR_COMPRESS
Constant for the "compress" index setting.

See Also:
Constant Field Values

STR_NO

public static final java.lang.String STR_NO
Constant for the "no" index setting.

See Also:
Constant Field Values

STR_TOKENIZED

public static final java.lang.String STR_TOKENIZED
Constant for the "tokenized" index setting.

See Also:
Constant Field Values

STR_UN_TOKENIZED

public static final java.lang.String STR_UN_TOKENIZED
Constant for the "untokenized" index setting.

See Also:
Constant Field Values

STR_YES

public static final java.lang.String STR_YES
Constant for the "yes" index setting.

See Also:
Constant Field Values
Constructor Detail

CmsLuceneField

public CmsLuceneField()
Creates a new search field configuration.


CmsLuceneField

public CmsLuceneField(java.lang.String name,
                      java.lang.String displayName,
                      boolean isStored,
                      boolean isIndexed)
Creates a new search field configuration.

The field will be tokenized if it is indexed. The field will not be in the excerpt. The boost value is the default, that is no special boost is used. There is no default value.

Parameters:
name - the name of the field, see CmsSearchField.setName(String)
displayName - the display name of this field, see setDisplayName(String)
isStored - controls if the field is stored and in the excerpt, see CmsSearchField.setStored(boolean)
isIndexed - controls if the field is indexed and tokenized, see CmsSearchField.setIndexed(boolean)

CmsLuceneField

public CmsLuceneField(java.lang.String name,
                      java.lang.String displayName,
                      boolean isStored,
                      boolean isCompressed,
                      boolean isIndexed,
                      boolean isTokenized,
                      boolean isInExcerpt,
                      org.apache.lucene.analysis.Analyzer analyzer,
                      float boost,
                      java.lang.String defaultValue)
Creates a new search field configuration.

Parameters:
name - the name of the field, see CmsSearchField.setName(String)
displayName - the display name of this field, see setDisplayName(String)
isStored - controls if the field is stored, see CmsSearchField.setStored(boolean)
isCompressed - controls if the filed is compressed, see setCompressed(boolean)
isIndexed - controls if the field is indexed, see CmsSearchField.setIndexed(boolean)
isTokenized - controls if the field is tokenized, see CmsSearchField.setStored(boolean)
isInExcerpt - controls if the field is in the excerpt, see isInExcerptAndStored()
analyzer - the analyzer to use, see setAnalyzer(Analyzer)
boost - the boost factor for the field, see CmsSearchField.setBoost(float)
defaultValue - the default value for the field, see CmsSearchField.setDefaultValue(String)

CmsLuceneField

public CmsLuceneField(java.lang.String name,
                      java.lang.String displayName,
                      boolean isStored,
                      boolean isIndexed,
                      boolean isTokenized,
                      boolean isInExcerpt,
                      float boost,
                      java.lang.String defaultValue)
Creates a new search field configuration.

Parameters:
name - the name of the field, see CmsSearchField.setName(String)
displayName - the display name of this field, see setDisplayName(String)
isStored - controls if the field is stored, see CmsSearchField.setStored(boolean)
isIndexed - controls if the field is indexed, see CmsSearchField.setIndexed(boolean)
isTokenized - controls if the field is tokenized, see CmsSearchField.setStored(boolean)
isInExcerpt - controls if the field is in the excerpt, see isInExcerptAndStored()
boost - the boost factor for the field, see CmsSearchField.setBoost(float)
defaultValue - the default value for the field, see CmsSearchField.setDefaultValue(String)
Method Detail

createField

public org.apache.lucene.document.Field createField(java.lang.String content)
Creates a field from the configuration and the provided content.

The configured name of the field as provided by CmsSearchField.getName() is used.

If no valid content is provided (that is the content is either null or only whitespace), then no field is created and null is returned.

Parameters:
content - the content to create the field with
Returns:
a field created from the configuration and the provided content

createField

public org.apache.lucene.document.Field createField(java.lang.String name,
                                                    java.lang.String content)
Creates a field with the given name from the configuration and the provided content.

If no valid content is provided (that is the content is either null or only whitespace), then no field is created and null is returned.

Parameters:
name - the name of the field to create
content - the content to create the field with
Returns:
a field with the given name from the configuration and the provided content

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer()
Returns the analyzer used for this field.

Returns:
the analyzer used for this field

getBoostDisplay

public java.lang.String getBoostDisplay()
Returns the boost factor of this field as String value for display use.

Returns:
the boost factor of this field as String value for display use

getDisplayName

public java.lang.String getDisplayName()
Returns the display name of the field.

Returns:
the display name of the field

getDisplayNameForConfiguration

public java.lang.String getDisplayNameForConfiguration()
Returns the displayNameForConfiguration.

Returns:
the displayNameForConfiguration

getIndexed

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

Overrides:
getIndexed in class CmsSearchField
Returns:
the String value state of this field if it is indexed (and possibly tokenized) in the Lucene index
See Also:
isTokenizedAndIndexed(), CmsSearchField.isIndexed()

getType

public java.lang.String getType()
Returns the type.

Returns:
the type

isCompressed

public boolean isCompressed()
Returns true if the content of this field is compressed.

If the field is compressed, it must also be stored, this means CmsSearchField.isStored() will always return true for compressed fields.

Returns:
true if the content of this field is compressed

isDisplayed

public boolean isDisplayed()
Returns true if the field should be displayed.

Returns:
returns true if the field should be displayed otherwise false

isInExcerptAndStored

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

A field can only be used in the excerpt if it is stored, see CmsSearchField.isStored().

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

isTokenized

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

Please refer to the Lucene documentation about Field.Index for the concept behind tokenized and untokenized fields.

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

isTokenizedAndIndexed

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

A field can only be tokenized if it is also indexed, see CmsSearchField.isIndexed().

Please refer to the Lucene documentation about Field.Index for the concept behind tokenized and untokenized fields.

Returns:
true if the content of this field is tokenized in the Lucene index
See Also:
CmsSearchField.isStored(), CmsSearchField.isIndexed()

setAnalyzer

public void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
Sets the analyzer used for this field.

Parameters:
analyzer - the analyzer to set

setAnalyzer

public void setAnalyzer(java.lang.String analyzerName)
                 throws java.lang.Exception
Sets the analyzer used for this field.

The parameter must be a name of a class the implements the Lucene Analyzer interface.

Parameters:
analyzerName - the analyzer class name to set
Throws:
java.lang.Exception - in case of problems creating the analyzer class instance

setBoostDisplay

public void setBoostDisplay(java.lang.String boost)
Sets the boost factor of this field (only for display use).

Parameters:
boost - the boost factor to set
See Also:
CmsSearchField.setBoost(String)

setCompressed

public void setCompressed(boolean compressed)
Controls if this field value will be stored compressed or not.

If this is set to true, the value for CmsSearchField.isStored() will also be set to true, since compressed fields are always stored.

Parameters:
compressed - if true, the field value will be stored compressed

setDisplayed

public void setDisplayed(boolean displayed)
Controls if the field is displayed or not.

Parameters:
displayed - if true the field is displayed

setDisplayName

public void setDisplayName(java.lang.String displayName)
Sets the display name. If the given name equals IGNORE_DISPLAY_NAME the field is not displayed.

Parameters:
displayName - the display name to set

setDisplayNameForConfiguration

public void setDisplayNameForConfiguration(java.lang.String displayNameForConfiguration)
Sets the displayNameForConfiguration.

Parameters:
displayNameForConfiguration - the displayNameForConfiguration to set

setIndexed

public void setIndexed(java.lang.String indexed)
Controls if the content of this field is indexed (and possibly tokenized) in the Lucene index from a String parameter.

This sets the values for CmsSearchField.isIndexed() as well as isTokenizedAndIndexed().

The parameter can have the following values:

Parameters:
indexed - the index setting to use
See Also:
CmsSearchField.setIndexed(boolean), setTokenized(boolean)

setInExcerpt

public void setInExcerpt(java.lang.String 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
See Also:
CmsSearchField.setInExcerpt(boolean)

setStored

public void setStored(java.lang.String stored)
Controls if the content of this field is stored in the Lucene index from a String parameter.

Parameters:
stored - if "true", then the field content is stored
See Also:
CmsSearchField.setStored(boolean)

setTokenized

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

Please refer to the Lucene documentation about Field.Index for the concept behind tokenized and untokenized fields.

Parameters:
tokenized - if true, then the field content is tokenized
See Also:
CmsSearchField.setStored(boolean)

setType

public void setType(java.lang.String type)
Sets the type.

Parameters:
type - the type to set