{"record":{"id":"3e5efbf8f2f26ec2","repo":"redis/redis-py","slug":"cannot-set-sortable-or-no-index-in-vector-fiel","errorCode":null,"errorMessage":"Cannot set 'sortable' or 'no_index' in Vector fields.","messagePattern":"Cannot set 'sortable' or 'no_index' in Vector fields\\.","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/search/field.py","lineNumber":195,"sourceCode":"    def __init__(self, name: str, algorithm: str, attributes: dict, **kwargs):\n        \"\"\"\n        Create Vector Field. Notice that Vector cannot have sortable or no_index tag,\n        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":177,"sourceCodeEnd":211,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/search/field.py#L177-L211","documentation":"Raised by VectorField.__init__() (redis/commands/search/field.py:195) as a DataError when kwargs include sortable or no_index. Vector fields cannot be made SORTABLE and are always indexed (NOINDEX is meaningless for vectors), so the client rejects these flags up front rather than letting the server reject the schema.","triggerScenarios":"Constructing VectorField('vec', 'FLAT', {...}, sortable=True) or VectorField('vec', 'HNSW', {...}, no_index=True). Passing these via **kwargs from a generic field-builder also triggers it.","commonSituations":"Reusing a generic field-construction helper that always forwards sortable/no_index, or assuming all field types support the same kwargs as TextField/NumericField.","solutions":["Do not pass sortable or no_index to VectorField.","If a generic builder forwards kwargs, filter them out for vector fields: {k: v for k, v in kwargs.items() if k not in ('sortable', 'no_index')}.","Vectors are implicitly indexed; there is no opt-out."],"exampleFix":"# before\nVectorField('embedding', 'FLAT', {'TYPE': 'FLOAT32', 'DIM': 128, 'DISTANCE_METRIC': 'L2'}, sortable=True)\n# after\nVectorField('embedding', 'FLAT', {'TYPE': 'FLOAT32', 'DIM': 128, 'DISTANCE_METRIC': 'L2'})","handlingStrategy":"validation","validationCode":"def safe_vector_kwargs(kwargs):\n    bad = {'sortable', 'no_index'} & set(kwargs)\n    if bad:\n        raise ValueError(f'VectorField does not accept {bad}')\n    return {k: v for k, v in kwargs.items() if k not in bad}","typeGuard":"def vector_kwargs_ok(kwargs) -> bool:\n    return not ({'sortable', 'no_index'} & set(kwargs))","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    VectorField(name, algo, attrs, **kwargs)\nexcept DataError as e:\n    if 'Vector fields' in str(e):\n        kwargs.pop('sortable', None); kwargs.pop('no_index', None)\n        VectorField(name, algo, attrs, **kwargs)\n    else:\n        raise","preventionTips":["Never forward sortable/no_index into VectorField.","Filter generic field-builder kwargs for vector fields.","Vectors are always indexed - there is no opt-out."],"tags":["search","vectorfield","dataerror","redisearch","vss"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}