Package com.redis.vl.schema
Class IndexSchema
java.lang.Object
com.redis.vl.schema.IndexSchema
Represents the schema definition for a Redis search index.
This class is final to prevent finalizer attacks, as it throws exceptions in constructors for input validation (SEI CERT OBJ11-J).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for IndexSchemastatic classInner class to hold index configurationstatic enumStorage type for documents in Redis -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a single fieldvoidAdd multiple fields from a list of mapsstatic IndexSchema.Builderbuilder()Create a builderbooleanstatic IndexSchemaCreate IndexSchema from dictionary (Map)static IndexSchemaCreate IndexSchema from JSON stringstatic IndexSchemaCreate IndexSchema from YAML stringstatic IndexSchemafromYamlFile(String filepath) Create IndexSchema from YAML fileGet a field by nameGet a copy of the fields listgetFieldsByType(Class<T> fieldType) Get fields of a specific typegetIndex()Get the index configuration (defensive copy)getName()Get the index nameGet the prefixGet the storage typebooleanCheck if a field existsinthashCode()static IndexSchema.BuilderCreate with fluent APIvoidremoveField(String name) Remove a field by nametoJson()Serialize to JSONtoYaml()Serialize to YAML
-
Method Details
-
fromYaml
Create IndexSchema from YAML string- Parameters:
yaml- the YAML string representation of the schema- Returns:
- an IndexSchema instance parsed from the YAML
-
fromYamlFile
Create IndexSchema from YAML file- Parameters:
filepath- the path to the YAML file containing the schema- Returns:
- an IndexSchema instance parsed from the YAML file
-
fromJson
Create IndexSchema from JSON string- Parameters:
json- the JSON string representation of the schema- Returns:
- an IndexSchema instance parsed from the JSON
-
fromDict
Create IndexSchema from dictionary (Map)- Parameters:
data- the map containing schema data- Returns:
- an IndexSchema instance created from the map
-
builder
Create a builder- Returns:
- a new Builder instance
-
of
Create with fluent API- Parameters:
name- the name of the index- Returns:
- a new Builder instance with the name set
-
getName
Get the index name- Returns:
- the index name
-
getPrefix
Get the prefix- Returns:
- the key prefix for documents in this index
-
getStorageType
Get the storage type- Returns:
- the storage type (HASH or JSON)
-
getFields
Get a copy of the fields list- Returns:
- a copy of the list of fields in this schema
-
getField
Get a field by name- Parameters:
name- the name of the field to retrieve- Returns:
- the field with the given name, or null if not found
-
hasField
Check if a field exists- Parameters:
name- the name of the field to check- Returns:
- true if a field with the given name exists, false otherwise
-
getFieldsByType
Get fields of a specific type- Type Parameters:
T- the type of field to retrieve- Parameters:
fieldType- the class of the field type- Returns:
- a list of fields matching the specified type
-
removeField
Remove a field by name- Parameters:
name- the name of the field to remove
-
addField
Add a single field- Parameters:
field- the field to add
-
addFields
Add multiple fields from a list of maps- Parameters:
fieldsData- list of maps containing field configuration data
-
toYaml
Serialize to YAML- Returns:
- YAML string representation of this schema
-
toJson
Serialize to JSON- Returns:
- JSON string representation of this schema
-
getIndex
Get the index configuration (defensive copy)- Returns:
- a copy of the Index configuration
-
equals
-
hashCode
public int hashCode()
-