Class SchemaField

  • All Implemented Interfaces:
    SchemaFieldProperties, java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>

    public class SchemaField
    extends java.lang.Object
    implements SchemaFieldProperties, java.lang.Iterable<java.lang.String>, java.io.Externalizable, java.lang.Cloneable
    Represents a field in the schema.
    See Also:
    Serialized Form
    • Field Detail

      • suffix

        protected java.lang.String suffix
    • Constructor Detail

      • SchemaField

        public SchemaField()
      • SchemaField

        public SchemaField​(java.lang.String fieldName)
        Construct a new String SchemaField.
        Parameters:
        fieldName - the field name
      • SchemaField

        public SchemaField​(java.lang.String fieldName,
                           SchemaField.Type fieldType)
        Construct a new typed SchemaField.
        Parameters:
        fieldName - the field name
        fieldType - the field type
      • SchemaField

        protected SchemaField​(java.lang.String name,
                              SchemaField.Type type,
                              boolean internal)
        Construct a new SchemaField.

        If internal is true, field name will not be validated.

    • Method Detail

      • checkFieldName

        public static final void checkFieldName​(java.lang.String name)
      • isNaturalLanguage

        public boolean isNaturalLanguage()
        true if field can be used for "natural language" processing.
      • getTokenizerName

        public java.lang.String getTokenizerName()
        Get the name of the tokenizer for this SchemaField.
      • isHighlight

        public boolean isHighlight()
        Gets if highlighting is enabled for this field.
      • setHighlight

        public void setHighlight​(boolean value)
        Gets if highlighting is enabled for this field.
      • isSingleValue

        public boolean isSingleValue()
        Get if this field is single valued.
      • setSingleValue

        public void setSingleValue​(boolean value)
        Set if this field is single valued.

        WARNING: changing this setting to true requires reindexing to ensure no documents contain multiple values for a field.

      • isMultiValue

        public boolean isMultiValue()
        Get if this field can support multiple field values per document.
      • setMultiValue

        public void setMultiValue​(boolean value)
        Set if this field can support multiple field values per document.

        WARNING: changing this setting to false requires reindexing to ensure no documents contain multiple values for a field.

      • isRealTime

        public boolean isRealTime()
        Returns true if this SchemaField has real time attributes.
      • setRealTime

        public void setRealTime​(boolean value)
      • isTokenized

        public boolean isTokenized()
        true if this field should be tokenized during ingestion.
      • setTokenized

        public void setTokenized​(boolean value)
      • setLowerCase

        public void setLowerCase​(boolean value)
      • isLowerCase

        public boolean isLowerCase()
        true if this field should be indexed in lower case.
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Get the included field names.
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
      • addIncludeField

        public void addIncludeField​(java.lang.String... fName)
        Add include field(s).
      • getIncludedFieldCount

        public int getIncludedFieldCount()
        Get the number of include fields.
      • getName

        public java.lang.String getName()
        Gets this SchemaField's name.
      • setName

        public void setName​(java.lang.String value)
        Sets this SchemaField's name.
      • isIndexed

        public boolean isIndexed()
        Gets if this SchemaField should be indexed.
      • setIndexed

        public void setIndexed​(boolean indexed)
        Sets if this SchemaField should be indexed.
      • isFacet

        public boolean isFacet()
        Gets if this SchemaField should be facetable.
      • isStored

        public boolean isStored()
        Gets if this SchemaField should be stored.
      • setStored

        public void setStored​(boolean value)
        Sets if this SchemaField should be stored.
      • isSort

        public boolean isSort()
        Gets if this SchemaField should support sorting.
      • setSort

        public void setSort​(boolean value)
        Sets if this SchemaField should support sorting.
      • getType

        public SchemaField.Type getType()
        Gets the Type of this SchemaField.
      • setType

        public void setType​(SchemaField.Type type)
        Sets the Type of this SchemaField.
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.String> getProperties()
        Properties configured for this field.
      • setProperties

        public void setProperties​(java.util.Map<java.lang.String,​java.lang.String> features)
        Sets the properties for this SchemaField.
      • addProperty

        public void addProperty​(java.lang.String propName,
                                java.lang.String propValue)
        Adds a property to the field.
        Parameters:
        propName - the property name
        propValue - the property value
      • getDefaultValue

        public java.lang.String getDefaultValue()
        Gets the default value for this SchemaField.
      • setDefaultValue

        public void setDefaultValue​(java.lang.String defaultValue)
        Sets the default value for this SchemaField.
      • containsProperty

        public boolean containsProperty​(java.lang.String property)
        Determine if the field has a given property.
      • getProperty

        public java.lang.String getProperty​(java.lang.String property)
        Get a field property by name.
      • getProperty

        public java.lang.String getProperty​(java.lang.String property,
                                            java.lang.String defaultVal)
        Get a field property by name with a default value.
      • getProperty

        public boolean getProperty​(java.lang.String property,
                                   boolean defaultVal)
        Get a field property by name with a default value.
      • getProperty

        public int getProperty​(java.lang.String property,
                               int pdefaultValue)
        Get a field property by name with a default value.
      • getProperty

        public long getProperty​(java.lang.String property,
                                long pdefaultValue)
        Get a field property by name with a default value.
      • getProperty

        public float getProperty​(java.lang.String property,
                                 float pdefaultValue)
        Get a field property by name with a default value.
      • getProperty

        public double getProperty​(java.lang.String property,
                                  double pdefaultValue)
        Get a field property by name with a default value.
      • isDynamic

        public boolean isDynamic()
        Gets if this SchemaField is dynamic.
      • setDynamic

        public void setDynamic​(boolean value)
        Sets if this SchemaField is dynamic.
      • isSameField

        public boolean isSameField​(java.lang.String fieldName)
        Determines if the field names are the same or a variant based on dynamic field name rules.
      • getDisplayName

        public java.lang.String getDisplayName()
        Gets the display name for this SchemaField.
      • setDisplayName

        public void setDisplayName​(java.lang.String displayName)
        Sets the display name for this SchemaField.
      • getSchemaFieldType

        public static SchemaField.Type getSchemaFieldType​(java.lang.Object o)
        Gets the data type for a given value
        Parameters:
        o - the value
        Returns:
        the type
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • isValidStaticField

        public static boolean isValidStaticField​(java.lang.String name)
        Returns true if name is a legal field name.
      • isValidDynamicField

        public static boolean isValidDynamicField​(java.lang.String name)
        Returns true if name is a legal dynamic field name.
      • getMaxTokens

        public int getMaxTokens()
      • setMaxTokens

        public void setMaxTokens​(int maxTokens)
      • clone

        public SchemaField clone()
        Overrides:
        clone in class java.lang.Object
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • writeExternal

        protected void writeExternal​(java.io.ObjectOutput out,
                                     boolean standalone)
                              throws java.io.IOException
        Throws:
        java.io.IOException