redis/redis-py · warning · ValueError

Non-Sortable non-Indexable fields are ignored

Error message

Non-Sortable non-Indexable fields are ignored

What it means

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.

Solutions

  1. If you want a sort-only field, set both no_index=True and sortable=True.
  2. If you want a normal searchable field, drop no_index (or set no_index=False).
  3. Remove the field from the schema entirely if you do not need search or sort on it.

Example fix

# before
TextField('title', no_index=True)
# after
TextField('title', no_index=True, sortable=True)
Defensive patterns

Strategy: validation

Validate before calling

def validate_field_flags(no_index, sortable):
    if no_index and not sortable:
        raise ValueError('a no_index field must also be sortable, else it is unusable')

Type guard

def valid_field_combo(no_index, sortable) -> bool:
    return not (no_index and not sortable)

Try / catch

try:
    TextField('x', no_index=no_idx, sortable=sort)
except ValueError as e:
    if 'Non-Sortable' in str(e):
        TextField('x', no_index=no_idx, sortable=True)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/1c6b83a6bcd74f52. Report an issue: GitHub.

Appendix: source

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

        """
        if args is None:
            args = []
        self.name = name
        self.args = args
        self.args_suffix = list()
        self.as_name = as_name

        if no_index:
            self.args_suffix.append(Field.NOINDEX)
        if index_missing:
            self.args_suffix.append(Field.INDEX_MISSING)
        if index_empty:
            self.args_suffix.append(Field.INDEX_EMPTY)
        if sortable:
            self.args_suffix.append(Field.SORTABLE)

        if no_index and not sortable:
            raise ValueError("Non-Sortable non-Indexable fields are ignored")

    def append_arg(self, value):
        self.args.append(value)

    def redis_args(self):
        args = [self.name]
        if self.as_name:
            args += [self.AS, self.as_name]
        args += self.args
        args += self.args_suffix
        return args


class TextField(Field):
    """
    TextField is used to define a text field in a schema definition
    """

View on GitHub (pinned to 6a6b581b48)