Class CmsLuceneField

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

public class CmsLuceneField extends CmsSearchField
An individual field configuration in a Lucene search index.

Since:
7.0.0
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • closeAnalyzer

      public void closeAnalyzer()
      Closes the analyzer.

    • createField

      public org.apache.lucene.document.Field createField(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(String name, 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
    • getDisplayName

      Returns the display name of the field.

      Returns:
      the display name of the field
    • getDisplayNameForConfiguration

      Returns the displayNameForConfiguration.

      Returns:
      the displayNameForConfiguration
    • getIndexed

      public 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:
    • getType

      public 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:
    • 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 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 the concept behind tokenized and untokenized fields.

      Returns:
      true if the content of this field is tokenized in the Lucene index
      See Also:
    • 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(String analyzerName) throws 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:
      Exception - in case of problems creating the analyzer class instance
    • 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(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(String displayNameForConfiguration)
      Sets the displayNameForConfiguration.

      Parameters:
      displayNameForConfiguration - the displayNameForConfiguration to set
    • setIndexed

      public void setIndexed(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:

      • "true" or "tokenized": The field is indexed and tokenized.
      • "false" or "no": The field is not indexed and not tokenized.
      • "untokenized": The field is indexed but not tokenized.
      Parameters:
      indexed - the index setting to use
      See Also:
    • setInExcerpt

      public void setInExcerpt(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:
    • setStored

      public void setStored(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:
    • 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 the concept behind tokenized and untokenized fields.

      Parameters:
      tokenized - if true, then the field content is tokenized
      See Also:
    • setType

      public void setType(String type)
      Sets the type.

      Parameters:
      type - the type to set