Skip to content

Conversation

@sgaluza
Copy link

@sgaluza sgaluza commented Jan 14, 2026

Summary

Add forward slash (/), backslash (\), and pipe (|) to the sanitize() method to prevent RediSearch query syntax errors.

Problem

When entity names contain certain special characters, RediSearch queries fail with syntax errors. The current sanitize() method handles most special characters but misses three important ones:

Character RediSearch Meaning Issue
| OR operator Breaks query logic
\ Escape character Causes parsing errors
/ Path separator Causes syntax errors (see #1144)

For example, an entity name like "Cruise / En route" would produce malformed queries.

Solution

Added the three missing characters to separator_map in sanitize():

'/': ' ',   # Forward slash - causes query syntax errors
'\\': ' ',  # Backslash - escape character in RediSearch
'|': ' ',   # Pipe - OR operator in RediSearch

Also updated the docstring with:

Research

RediSearch reserved characters that require escaping (from official docs):

  • Tokenization separators: ,.<>{}[]"':;!@#$%^&*()-+=~?
  • Query operators: | (OR), - (negation), * and ? (wildcards)
  • Escape character: \

The existing code already handles most of these, this PR adds the missing ones.

Related

Test Plan

  • Verify "Cruise / En route""Cruise En route"
  • Verify "path\\to\\file""path to file"
  • Verify "option1|option2""option1 option2"

Built with OnSteroids

Add forward slash (/), backslash (\), and pipe (|) to the sanitize()
method to prevent RediSearch query syntax errors.

RediSearch uses these characters with special meaning:
- | is the OR operator
- \ is the escape character
- / causes query syntax errors in entity names

Updated docstring with:
- Reference to RediSearch escaping documentation
- Note that this is for fulltext search, not exact path matching

Fixes getzep#1144
Related to getzep#1118

Built with [OnSteroids](https://onsteroids.ai)

Co-Authored-By: OnSteroids <[email protected]>
@danielchalef
Copy link
Member

danielchalef commented Jan 14, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sgaluza
Copy link
Author

sgaluza commented Jan 14, 2026

I have read the CLA Document and I hereby sign the CLA

danielchalef added a commit that referenced this pull request Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FalkorDriver sanitize should escape forward/back slashes for RediSearch

2 participants