{"id":"2c639f69ea5f2adb","repo":"redis/redis-py","slug":"realtime-vector-indexing-supporting-3-indexing-met","errorCode":null,"errorMessage":"Realtime vector indexing supporting 3 Indexing Methods:'FLAT', 'HNSW', and 'SVS-VAMANA'.","messagePattern":"Realtime vector indexing supporting 3 Indexing Methods:'FLAT', 'HNSW', and 'SVS-VAMANA'\\.","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/search/field.py","lineNumber":198,"sourceCode":"        although it's also a Field.\n\n        ``name`` is the name of the field.\n\n        ``algorithm`` can be \"FLAT\", \"HNSW\", or \"SVS-VAMANA\".\n\n        ``attributes`` each algorithm can have specific attributes. Some of them\n        are mandatory and some of them are optional. See\n        https://oss.redis.com/redisearch/master/Vectors/#specific_creation_attributes_per_algorithm\n        for more information.\n        \"\"\"\n        sort = kwargs.get(\"sortable\", False)\n        noindex = kwargs.get(\"no_index\", False)\n\n        if sort or noindex:\n            raise DataError(\"Cannot set 'sortable' or 'no_index' in Vector fields.\")\n\n        if algorithm.upper() not in [\"FLAT\", \"HNSW\", \"SVS-VAMANA\"]:\n            raise DataError(\n                \"Realtime vector indexing supporting 3 Indexing Methods:\"\n                \"'FLAT', 'HNSW', and 'SVS-VAMANA'.\"\n            )\n\n        attr_li = []\n\n        for key, value in attributes.items():\n            attr_li.extend([key, value])\n\n        Field.__init__(\n            self, name, args=[Field.VECTOR, algorithm, len(attr_li), *attr_li], **kwargs\n        )\n","sourceCodeStart":180,"sourceCodeEnd":211,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/search/field.py#L180-L211","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Use one of 'FLAT', 'HNSW', or 'SVS-VAMANA' (case-insensitive).","If using SVS-VAMANA, verify your RediSearch build supports it.","Validate algorithm against the allowed set before constructing the field."],"exampleFix":"// before\nVectorField('vec', 'IVF', {'TYPE': 'FLOAT32', 'DIM': 128})\n// after\nVectorField('vec', 'FLAT', {'TYPE': 'FLOAT32', 'DIM': 128, 'DISTANCE_METRIC': 'L2'})","handlingStrategy":"validation","validationCode":"VALID_ALGOS = {\"FLAT\", \"HNSW\", \"SVS-VAMANA\"}\n\ndef make_vector_field(name, algorithm, attributes):\n    algo = algorithm.upper() if isinstance(algorithm, str) else \"\"\n    if algo not in VALID_ALGOS:\n        raise ValueError(f\"algorithm must be one of {VALID_ALGOS}, got {algorithm!r}\")\n    from redis.commands.search.field import VectorField\n    return VectorField(name, algo, attributes)","typeGuard":"def is_valid_vector_algorithm(v) -> bool:\n    return isinstance(v, str) and v.upper() in {\"FLAT\", \"HNSW\", \"SVS-VAMANA\"}","tryCatchPattern":"from redis import DataError\ntry:\n    VectorField(\"vec\", algorithm, attrs)\nexcept DataError as e:\n    if \"Indexing Methods\" in str(e):\n        VectorField(\"vec\", \"FLAT\", attrs)  # safe fallback\n    else:\n        raise","preventionTips":["Restrict algorithm choice in your schema builder to a constant set.","Uppercase user input before validation — matching is case-insensitive in the library but your UI may not be.","Confirm server-side support for SVS-VAMANA on older RediSearch builds."],"tags":["redis-search","vector","schema","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}