-
Notifications
You must be signed in to change notification settings - Fork 75
fix: pass withsuffixtrie attribute to Redis Text and Tag fields #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,6 +400,10 @@ def as_redis_field(self) -> RedisField: | |
| if self.attrs.phonetic_matcher is not None: # type: ignore | ||
| kwargs["phonetic_matcher"] = self.attrs.phonetic_matcher # type: ignore | ||
|
|
||
| # Add WITHSUFFIXTRIE if enabled | ||
| if self.attrs.withsuffixtrie: # type: ignore | ||
| kwargs["withsuffixtrie"] = True | ||
|
|
||
| # Add INDEXMISSING if enabled | ||
| if self.attrs.index_missing: # type: ignore | ||
| kwargs["index_missing"] = True | ||
|
|
@@ -442,6 +446,10 @@ def as_redis_field(self) -> RedisField: | |
| if as_name is not None: | ||
| kwargs["as_name"] = as_name | ||
|
|
||
| # Add WITHSUFFIXTRIE if enabled | ||
| if self.attrs.withsuffixtrie: # type: ignore | ||
| kwargs["withsuffixtrie"] = True | ||
|
Comment on lines
+449
to
+451
|
||
|
|
||
| # Add INDEXMISSING if enabled | ||
| if self.attrs.index_missing: # type: ignore | ||
| kwargs["index_missing"] = True | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,190 @@ | ||||
| """ | ||||
| Integration tests for withsuffixtrie attribute on Text and Tag fields. | ||||
|
|
||||
| Tests verify that the WITHSUFFIXTRIE modifier is correctly passed to Redis | ||||
| when creating indexes, enabling optimized suffix and contains queries. | ||||
| """ | ||||
|
|
||||
| import pytest | ||||
|
|
||||
|
Comment on lines
+8
to
+9
|
||||
| import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_normalize_field_modifiers()overwritesfield.args_suffixwith only the modifiers listed incanonical_order. SinceWITHSUFFIXTRIEis not included in that list, enablingwithsuffixtriehere is likely to be stripped back out beforeFT.CREATEis issued. Consider either (a) includingWITHSUFFIXTRIEin the canonical order for TEXT fields, or (b) updating_normalize_field_modifiersto preserve non-canonical suffix modifiers while reordering the known ones.