redis/redis-py · error · ValueError

Non-Sortable non-Indexable fields are ignored

Error message

Non-Sortable non-Indexable fields are ignored

What it means

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.

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 da03cdc7e8)

Solutions

  1. If the field should be sortable but not searchable: add sortable=True.
  2. If the field should be neither, drop it from the schema entirely.
  3. If you need no_index, pair it with sortable=True so the field remains useful for sorting.

Example fix

// before
TextField('name', no_index=True)
// after
TextField('name', no_index=True, sortable=True)
// or just remove the field if unused
Defensive patterns

Strategy: validation

Validate before calling

def make_field(cls, name, **kw):
    no_index = kw.get("no_index", False)
    sortable = kw.get("sortable", False)
    if no_index and not sortable:
        raise ValueError(
            f"{name}: no_index=True requires sortable=True, "
            "otherwise the field is invisible to search"
        )
    return cls(name, **kw)

Type guard

def field_is_useful(no_index: bool, sortable: bool) -> bool:
    return not no_index or sortable

Try / catch

try:
    TextField("name", no_index=True)
except ValueError as e:
    if "Non-Sortable non-Indexable" in str(e):
        TextField("name", no_index=True, sortable=True)
    else:
        raise

Prevention

When it happens

Trigger: Construct any Field subclass (TextField, NumericField, TagField, etc.) with no_index=True but sortable omitted/False, e.g. TextField('name', no_index=True).

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

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/1c6b83a6bcd74f52.json. Report an issue: GitHub.