Skip to content

Bug: withsuffixtrie Attribute Not Passed to Redis #535

@nkanu17

Description

@nkanu17

Component: redisvl/schema/fields.py

Summary

The withsuffixtrie attribute is defined in TextFieldAttributes and TagFieldAttributes but is never passed to the underlying Redis field constructors in as_redis_field() methods.

Expected Behavior

When a user defines a text or tag field with withsuffixtrie: true, the index should be created with the WITHSUFFIXTRIE modifier, enabling optimized suffix/contains queries.

Actual Behavior

The attribute is silently ignored. The index is created without suffix trie support even when specified.

Root Cause

In redisvl/schema/fields.py:

TextField.as_redis_field() (around line 245):

return RedisTextField(
    self.name,
    weight=self.attrs.weight,
    no_stem=self.attrs.no_stem,
    phonetic_matcher=self.attrs.phonetic_matcher,
    sortable=self.attrs.sortable,
    no_index=self.attrs.no_index,
    # MISSING: withsuffixtrie=self.attrs.withsuffixtrie
)

TagField.as_redis_field() (around line 306):

return RedisTagField(
    self.name,
    separator=self.attrs.separator,
    case_sensitive=self.attrs.case_sensitive,
    sortable=self.attrs.sortable,
    no_index=self.attrs.no_index,
    # MISSING: withsuffixtrie=self.attrs.withsuffixtrie
)

Solution

Add withsuffixtrie parameter to both RedisTextField() and RedisTagField() constructor calls.

Verification

After fix, create an index with:

fields:
  - name: description
    type: text
    attrs:
      withsuffixtrie: true

Then verify with FT.INFO that the field has the WITHSUFFIXTRIE modifier.

Files to Modify

  • redisvl/schema/fields.py - TextField.as_redis_field() and TagField.as_redis_field()

Testing

Add integration test:

def test_withsuffixtrie_is_applied():
    schema_dict = {
        "index": {"name": "test_suffix", "prefix": "suffix:", "storage_type": "hash"},
        "fields": [{"name": "title", "type": "text", "attrs": {"withsuffixtrie": True}}],
    }
    schema = IndexSchema.from_dict(schema_dict)
    index = SearchIndex(schema=schema, redis_url=redis_url)
    index.create(overwrite=True)
    
    info = client.execute_command("FT.INFO", "test_suffix")
    # Assert WITHSUFFIXTRIE appears in field definition

Branch Name

fix/withsuffixtrie-not-passed

Related

  • Discovered during field attributes research (Phase 1)
  • Tracked in nitin_docs/field_attributes_research.md

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions