From 9e7e6e10a44da6a4d6e04d97d6b7294a695580c5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:39:08 +0000 Subject: [PATCH] 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> --- doctests/query-em.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doctests/query-em.js b/doctests/query-em.js index 9b5782e09c..8660c5a44a 100644 --- a/doctests/query-em.js +++ b/doctests/query-em.js @@ -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