"""Schema for tag fields in Redis."""
    separator: str = ","
    case_sensitive: bool = False
    no_index: bool = False
    sortable: Optional[bool] = False
[docs]    def as_field(self) -> TagField:
        from redis.commands.search.field import TagField  # type: ignore
        return TagField(
            self.name,
            separator=self.separator,
            case_sensitive=self.case_sensitive,
            sortable=self.sortable,
            no_index=self.no_index,
        )
[docs]class NumericFieldSchema(RedisField):
    """Schema for numeric fields in Redis."""
    no_index: bool = False
    sortable: Optional[bool] = False
[docs]    def as_field(self) -> NumericField:
        from redis.commands.search.field import NumericField  # type: ignore
        return NumericField(self.name, sortable=self.sortable, no_index=self.no_index)
[docs]class RedisVectorField(RedisField):
    """Base class for Redis vector fields."""
    dims: int = Field(...)
    algorithm: object = Field(...)
    datatype: str = Field(default="FLOAT32")
    distance_metric: RedisDistanceMetric = Field(default="COSINE")
    initial_cap: Optional[int] = None
    @validator("algorithm", "datatype", "distance_metric", pre=True, each_item=True)
    def uppercase_strings(cls, v: str) -> str:
        return v.upper()
    @validator("datatype", pre=True)
    def uppercase_and_check_dtype(cls, v: str) -> str:
        if v.upper() not in REDIS_VECTOR_DTYPE_MAP:
            raise ValueError(
                f"datatype must be one of {REDIS_VECTOR_DTYPE_MAP.keys()}. Got {v}"
            )
        return v.upper()