Class BaseField

java.lang.Object
com.redis.vl.schema.BaseField
Direct Known Subclasses:
GeoField, NumericField, TagField, TextField, VectorField

public abstract class BaseField extends Object
Base class for all field types in RedisVL. Provides common functionality for all field implementations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
    Optional alias for the field
    protected final boolean
    Whether this field should be indexed
    protected final String
    The name of the field in Redis
    protected final boolean
    Whether this field is sortable
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Create a field with just a name (defaults: indexed=true, sortable=false).
    protected
    BaseField(String name, String alias, boolean indexed, boolean sortable)
    Create a field with all properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    protected final void
    Empty finalizer to prevent finalizer attacks on subclasses.
    abstract FieldType
    Get the field type.
    int
     
    Convert to Jedis FieldName for query building.
    abstract SchemaField
    Convert to Jedis SchemaField for index creation.
    Serialize this field to JSON.
     

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      protected final String name
      The name of the field in Redis
    • alias

      protected final String alias
      Optional alias for the field
    • indexed

      protected final boolean indexed
      Whether this field should be indexed
    • sortable

      protected final boolean sortable
      Whether this field is sortable
  • Constructor Details

    • BaseField

      protected BaseField(String name)
      Create a field with just a name (defaults: indexed=true, sortable=false).
      Parameters:
      name - The name of the field in Redis
    • BaseField

      protected BaseField(String name, String alias, boolean indexed, boolean sortable)
      Create a field with all properties.
      Parameters:
      name - The name of the field in Redis
      alias - Optional alias for the field
      indexed - Whether this field should be indexed
      sortable - Whether this field is sortable
  • Method Details

    • getFieldType

      public abstract FieldType getFieldType()
      Get the field type.
      Returns:
      The field type enumeration
    • toJedisSchemaField

      public abstract SchemaField toJedisSchemaField()
      Convert to Jedis SchemaField for index creation.
      Returns:
      The Jedis schema field representation
    • toJedisFieldName

      public FieldName toJedisFieldName()
      Convert to Jedis FieldName for query building.
      Returns:
      The Jedis field name representation
    • toJson

      public String toJson()
      Serialize this field to JSON.
      Returns:
      JSON string representation of this field
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • finalize

      protected final void finalize()
      Empty finalizer to prevent finalizer attacks on subclasses.

      Per SEI CERT OBJ11-J, classes that throw exceptions in constructors should have an empty final finalizer to prevent finalizer attacks through subclassing.

      Note: finalize() is deprecated but required here for security (prevent finalizer attacks).

      Overrides:
      finalize in class Object
      See Also: