Package com.redis.vl.utils
Class TokenEscaper
java.lang.Object
com.redis.vl.utils.TokenEscaper
Escape punctuation within an input string.
Ported from Python: redisvl/utils/token_escaper.py
Adapted from RedisOM Python.
Characters that RediSearch requires us to escape during queries.
Source: Redis Search Escaping
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor using default escaped characters.TokenEscaper
(Pattern escapeCharsPattern) Constructor with custom escape pattern. -
Method Summary
-
Constructor Details
-
TokenEscaper
public TokenEscaper()Default constructor using default escaped characters. -
TokenEscaper
Constructor with custom escape pattern.- Parameters:
escapeCharsPattern
- custom pattern for characters to escape
-
-
Method Details
-
escape
Escape special characters in the input string.Python equivalent:
def escape(self, value: str) -> str: def escape_symbol(match): value = match.group(0) return f"\\{value}" return self.escaped_chars_re.sub(escape_symbol, value)
- Parameters:
value
- the string to escape- Returns:
- escaped string
- Throws:
IllegalArgumentException
- if value is not a string
-