Skip to content

Commit 9e7e6e1

Browse files
Copilotnkaradzhov
andcommitted
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>
1 parent 21490cf commit 9e7e6e1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

doctests/query-em.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ await client.ft.create('idx:email', {
9595

9696
await client.json.set('key:1', '$', { email: 'test@redis.com' });
9797

98-
try {
99-
const res6 = await client.ft.search('idx:email', 'test@redis.com', { DIALECT: 2 });
100-
console.log(res6);
101-
} catch (err) {
102-
console.log("'test@redis.com' syntax not yet supported.");
103-
}
98+
// Escape special characters (. and @) in the email address for TAG field search
99+
const emailAddress = 'test@redis.com'.replace(/[.@\\]/g, '\\$&');
100+
const res6 = await client.ft.search('idx:email', `@email:{${emailAddress}}`);
101+
console.log(res6.total); // >>> 1
104102
// REMOVE_START
103+
assert.strictEqual(res6.total, 1);
105104
await client.ft.dropIndex('idx:email', { DD: true });
106105
// REMOVE_END
107106
// STEP_END

0 commit comments

Comments
 (0)