{"record":{"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":"warning","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/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/search/field.py#L47-L83","documentation":"Raised by Field.__init__() (redis/commands/search/field.py:65) as a ValueError when no_index=True and sortable=False. A field that is neither indexed nor sortable is invisible to both search and sort, so the library treats it as a user error rather than silently emitting a useless schema entry.","triggerScenarios":"Constructing any Field subclass with no_index=True and sortable=False (sortable defaults to False), e.g. TextField('x', no_index=True) with no sortable=True.","commonSituations":"Intending a sort-only field but forgetting sortable=True, or intending to suppress indexing while keeping sortability. A no_index field is only meaningful together with sortable (so it can be SORTBY'd without being searchable).","solutions":["If you want a sort-only field, set both no_index=True and sortable=True.","If you want a normal searchable field, drop no_index (or set no_index=False).","Remove the field from the schema entirely if you do not need search or sort on it."],"exampleFix":"# before\nTextField('title', no_index=True)\n# after\nTextField('title', no_index=True, sortable=True)","handlingStrategy":"validation","validationCode":"def validate_field_flags(no_index, sortable):\n    if no_index and not sortable:\n        raise ValueError('a no_index field must also be sortable, else it is unusable')","typeGuard":"def valid_field_combo(no_index, sortable) -> bool:\n    return not (no_index and not sortable)","tryCatchPattern":"try:\n    TextField('x', no_index=no_idx, sortable=sort)\nexcept ValueError as e:\n    if 'Non-Sortable' in str(e):\n        TextField('x', no_index=no_idx, sortable=True)\n    else:\n        raise","preventionTips":["Pair no_index=True with sortable=True for sort-only fields.","Drop no_index for normal searchable fields.","Omit the field entirely if you need neither search nor sort."],"tags":["search","field","schema","valueerror","redisearch"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}