redis/redis-py · error · DataError

Realtime vector indexing supporting 3 Indexing Methods:'FLAT

Error message

Realtime vector indexing supporting 3 Indexing Methods:'FLAT', 'HNSW', and 'SVS-VAMANA'.

What it means

Raised by VectorField.__init__ when algorithm.upper() is not one of 'FLAT', 'HNSW', or 'SVS-VAMANA'. These are the only three vector indexing methods RediSearch supports (SVS-VAMANA was added more recently). The constructor upper-cases the input, so case does not matter, but the string must exactly match one of the three. Note: raises DataError.

Source

Thrown at redis/commands/search/field.py:198

        although it's also a Field.

        ``name`` is the name of the field.

        ``algorithm`` can be "FLAT", "HNSW", or "SVS-VAMANA".

        ``attributes`` each algorithm can have specific attributes. Some of them
        are mandatory and some of them are optional. See
        https://oss.redis.com/redisearch/master/Vectors/#specific_creation_attributes_per_algorithm
        for more information.
        """
        sort = kwargs.get("sortable", False)
        noindex = kwargs.get("no_index", False)

        if sort or noindex:
            raise DataError("Cannot set 'sortable' or 'no_index' in Vector fields.")

        if algorithm.upper() not in ["FLAT", "HNSW", "SVS-VAMANA"]:
            raise DataError(
                "Realtime vector indexing supporting 3 Indexing Methods:"
                "'FLAT', 'HNSW', and 'SVS-VAMANA'."
            )

        attr_li = []

        for key, value in attributes.items():
            attr_li.extend([key, value])

        Field.__init__(
            self, name, args=[Field.VECTOR, algorithm, len(attr_li), *attr_li], **kwargs
        )

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Use one of 'FLAT', 'HNSW', or 'SVS-VAMANA' (case-insensitive).
  2. If using SVS-VAMANA, verify your RediSearch build supports it.
  3. Validate algorithm against the allowed set before constructing the field.

Example fix

// before
VectorField('vec', 'IVF', {'TYPE': 'FLOAT32', 'DIM': 128})
// after
VectorField('vec', 'FLAT', {'TYPE': 'FLOAT32', 'DIM': 128, 'DISTANCE_METRIC': 'L2'})
Defensive patterns

Strategy: validation

Validate before calling

VALID_ALGOS = {"FLAT", "HNSW", "SVS-VAMANA"}

def make_vector_field(name, algorithm, attributes):
    algo = algorithm.upper() if isinstance(algorithm, str) else ""
    if algo not in VALID_ALGOS:
        raise ValueError(f"algorithm must be one of {VALID_ALGOS}, got {algorithm!r}")
    from redis.commands.search.field import VectorField
    return VectorField(name, algo, attributes)

Type guard

def is_valid_vector_algorithm(v) -> bool:
    return isinstance(v, str) and v.upper() in {"FLAT", "HNSW", "SVS-VAMANA"}

Try / catch

from redis import DataError
try:
    VectorField("vec", algorithm, attrs)
except DataError as e:
    if "Indexing Methods" in str(e):
        VectorField("vec", "FLAT", attrs)  # safe fallback
    else:
        raise

Prevention

When it happens

Trigger: Construct VectorField(name, algorithm='IVF', attributes={...}) or any algorithm string not in {FLAT, HNSW, SVS-VAMANA} (case-insensitive); also triggered by a non-string algorithm without .upper() (AttributeError actually — but the DataError fires for unknown string algorithms).

Common situations: Typos ('HNSW2', 'FLAT2'); using an algorithm name from a different vector DB (e.g. 'IVF_PQ', 'HNSWLIB'); targeting an older RediSearch that does not yet support SVS-VAMANA.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/2c639f69ea5f2adb.json. Report an issue: GitHub.