Skip to content

Incorrect argument order for RediSearch field flags (INDEXMISSING / INDEXEMPTY with SORTABLE) #3809

@xinweiiiii

Description

@xinweiiiii

Description

When using redis-py with RediSearch, the parser currently expects the INDEXMISSING or INDEXEMPTY flags to appear before SORTABLE. However, the current implementation appends SORTABLE first, leading to an error when SORTABLE precedes the missing/empty flags.

if sortable:
    self.args_suffix.append(Field.SORTABLE)
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)

This causes parsing errors when SORTABLE is placed before INDEXMISSING or INDEXEMPTY.

Expected behavior:

INDEXMISSING and INDEXEMPTY should be emitted before SORTABLE, to align with RediSearch’s parser expectations.

Suggested fix:

Reorder the code to emit INDEXMISSING and INDEXEMPTY before SORTABLE.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions