{"id":"1c6b83a6bcd74f52","repo":"redis/redis-py","slug":"non-sortable-non-indexable-fields-are-ignored","errorCode":null,"errorMessage":"Non-Sortable non-Indexable fields are ignored","messagePattern":"Non-Sortable non-Indexable fields are ignored","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/commands/search/field.py","lineNumber":65,"sourceCode":"        \"\"\"\n        if args is None:\n            args = []\n        self.name = name\n        self.args = args\n        self.args_suffix = list()\n        self.as_name = as_name\n\n        if no_index:\n            self.args_suffix.append(Field.NOINDEX)\n        if index_missing:\n            self.args_suffix.append(Field.INDEX_MISSING)\n        if index_empty:\n            self.args_suffix.append(Field.INDEX_EMPTY)\n        if sortable:\n            self.args_suffix.append(Field.SORTABLE)\n\n        if no_index and not sortable:\n            raise ValueError(\"Non-Sortable non-Indexable fields are ignored\")\n\n    def append_arg(self, value):\n        self.args.append(value)\n\n    def redis_args(self):\n        args = [self.name]\n        if self.as_name:\n            args += [self.AS, self.as_name]\n        args += self.args\n        args += self.args_suffix\n        return args\n\n\nclass TextField(Field):\n    \"\"\"\n    TextField is used to define a text field in a schema definition\n    \"\"\"\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/search/field.py#L47-L83","documentation":"Raised by the Field base constructor when no_index=True and sortable is False (the default). A field that is neither indexed nor sortable is invisible to RediSearch — it can neither be queried nor sorted on — so the client treats the combination as a configuration error rather than silently emitting a useless schema entry. Note: this raises ValueError, not DataError.","triggerScenarios":"Construct any Field subclass (TextField, NumericField, TagField, etc.) with no_index=True but sortable omitted/False, e.g. TextField('name', no_index=True).","commonSituations":"Trying to make a field 'storage-only' by setting no_index and forgetting sortable; copy-pasting field definitions and dropping sortable=True; programmatically building a schema where a flag was mis-set.","solutions":["If the field should be sortable but not searchable: add sortable=True.","If the field should be neither, drop it from the schema entirely.","If you need no_index, pair it with sortable=True so the field remains useful for sorting."],"exampleFix":"// before\nTextField('name', no_index=True)\n// after\nTextField('name', no_index=True, sortable=True)\n// or just remove the field if unused","handlingStrategy":"validation","validationCode":"def make_field(cls, name, **kw):\n    no_index = kw.get(\"no_index\", False)\n    sortable = kw.get(\"sortable\", False)\n    if no_index and not sortable:\n        raise ValueError(\n            f\"{name}: no_index=True requires sortable=True, \"\n            \"otherwise the field is invisible to search\"\n        )\n    return cls(name, **kw)","typeGuard":"def field_is_useful(no_index: bool, sortable: bool) -> bool:\n    return not no_index or sortable","tryCatchPattern":"try:\n    TextField(\"name\", no_index=True)\nexcept ValueError as e:\n    if \"Non-Sortable non-Indexable\" in str(e):\n        TextField(\"name\", no_index=True, sortable=True)\n    else:\n        raise","preventionTips":["Pair every no_index=True with sortable=True, or drop the field entirely.","Validate schema building in a unit test that constructs every Field once.","Don't apply a blanket 'no_index everywhere' flag without checking sortable."],"tags":["redis-search","schema","validation","field","valueerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}