fix: pass withsuffixtrie attribute to Redis Text and Tag fields#536
fix: pass withsuffixtrie attribute to Redis Text and Tag fields#536
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a schema-to-Redis translation gap by ensuring the withsuffixtrie attribute on TextFieldAttributes / TagFieldAttributes is actually forwarded into the underlying Redis search field definitions, and adds integration coverage to validate the modifier shows up in FT.INFO.
Changes:
- Pass
withsuffixtrie=TruethroughTextField.as_redis_field()intoRedisTextField(...). - Pass
withsuffixtrie=TruethroughTagField.as_redis_field()intoRedisTagField(...). - Add integration tests that create indexes with
withsuffixtrieand assertWITHSUFFIXTRIEappears in the field attributes returned byFT.INFO.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
redisvl/schema/fields.py |
Forwards withsuffixtrie from schema field attributes into Redis field constructor kwargs for TEXT and TAG fields. |
tests/integration/test_withsuffixtrie_integration.py |
Adds integration tests verifying WITHSUFFIXTRIE is present in FT.INFO attributes for TEXT/TAG fields when enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import pytest | ||
|
|
There was a problem hiding this comment.
pytest is imported but not used in this test module. Consider removing the import to avoid dead code / keep the test file minimal (or use it for an explicit skip/marker if intended).
| import pytest |
The withsuffixtrie attribute was defined in TextFieldAttributes and TagFieldAttributes but never passed to the underlying Redis field constructors in as_redis_field() methods. - Add withsuffixtrie parameter to RedisTextField constructor call - Add withsuffixtrie parameter to RedisTagField constructor call - Add integration tests to verify WITHSUFFIXTRIE modifier in FT.INFO
ab0dbd0 to
7267056
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Add WITHSUFFIXTRIE if enabled | ||
| if self.attrs.withsuffixtrie: # type: ignore | ||
| kwargs["withsuffixtrie"] = True |
There was a problem hiding this comment.
_normalize_field_modifiers() overwrites field.args_suffix with only the modifiers listed in canonical_order. Since WITHSUFFIXTRIE is not included in that list, enabling withsuffixtrie here is likely to be stripped back out before FT.CREATE is issued. Consider either (a) including WITHSUFFIXTRIE in the canonical order for TEXT fields, or (b) updating _normalize_field_modifiers to preserve non-canonical suffix modifiers while reordering the known ones.
| # Add WITHSUFFIXTRIE if enabled | ||
| if self.attrs.withsuffixtrie: # type: ignore | ||
| kwargs["withsuffixtrie"] = True |
There was a problem hiding this comment.
Same issue as TEXT: after setting kwargs["withsuffixtrie"] = True, _normalize_field_modifiers() will reset args_suffix to only INDEXEMPTY/INDEXMISSING/SORTABLE/NOINDEX. If WITHSUFFIXTRIE is represented as a suffix modifier by redis-py, it will be dropped and the index will be created without suffix trie support. Update the canonical order to include WITHSUFFIXTRIE (or make _normalize_field_modifiers preserve unknown modifiers).
Related: #535
The withsuffixtrie attribute was defined in TextFieldAttributes and TagFieldAttributes but never passed to the underlying Redis field constructors in as_redis_field() methods. This meant the attribute was silently ignored - indexes were created without suffix trie support even when explicitly specified.
Solution
Changes
Note
Low Risk
Low risk: the change only affects index creation when
withsuffixtrieis explicitly enabled, plus adds integration coverage to detect regressions.Overview
Fixes schema-to-Redis field translation so
TextField.as_redis_field()andTagField.as_redis_field()now passwithsuffixtrie=Trueto the underlying Redis field constructors when the attribute is enabled.Adds integration tests that create indexes with
withsuffixtrie(and in combination withsortable/case_sensitive) and assertWITHSUFFIXTRIEappears inFT.INFOfield attributes.Written by Cursor Bugbot for commit 7267056. This will update automatically on new commits. Configure here.