You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-09 21:21:11 +03:00
Fix TAG field search with special characters in doctest
- Remove incorrect try-catch block that hid the real issue
- Add proper escaping for special characters (@ and .) in email address
- Use correct search syntax: @email:{escaped_value}
- Add assertion to verify the search returns 1 result
- Add explanatory comment about escaping
Co-authored-by: nkaradzhov <1475500+nkaradzhov@users.noreply.github.com>
This commit is contained in:
@@ -95,13 +95,12 @@ await client.ft.create('idx:email', {
|
||||
|
||||
await client.json.set('key:1', '$', { email: 'test@redis.com' });
|
||||
|
||||
try {
|
||||
const res6 = await client.ft.search('idx:email', 'test@redis.com', { DIALECT: 2 });
|
||||
console.log(res6);
|
||||
} catch (err) {
|
||||
console.log("'test@redis.com' syntax not yet supported.");
|
||||
}
|
||||
// Escape special characters (. and @) in the email address for TAG field search
|
||||
const emailAddress = 'test@redis.com'.replace(/[.@\\]/g, '\\$&');
|
||||
const res6 = await client.ft.search('idx:email', `@email:{${emailAddress}}`);
|
||||
console.log(res6.total); // >>> 1
|
||||
// REMOVE_START
|
||||
assert.strictEqual(res6.total, 1);
|
||||
await client.ft.dropIndex('idx:email', { DD: true });
|
||||
// REMOVE_END
|
||||
// STEP_END
|
||||
|
||||
Reference in New Issue
Block a user