Open
Description
Description
hello, i don't know why but exact match and params dont seems to works together.
Reproduction
import { createClient, SchemaFieldTypes } from 'redis';
import { GenericContainer } from 'testcontainers';
(async () => {
const redisClient = await new GenericContainer(
'redis/redis-stack-server:7.2.0-RC1-arm64'
)
.withExposedPorts(6379)
.start()
.then((container) => {
const client = createClient({ url: `redis://${container.getHost()}:${container.getMappedPort(6379)}` });
client.on('end', async () => await container.stop());
client.on('error', (err) => console.log('Redis Client Error', err));
return client.connect().then(() => client);
});
await redisClient.json.set(`noderedis:users:0`, '$', {
name: 'Alice Johnson',
age: 32,
coins: 100
});
await redisClient.ft.create('idx:users', {
'$.name': {
type: SchemaFieldTypes.TEXT,
SORTABLE: 'UNF',
AS: 'name'
},
'$.age': {
type: SchemaFieldTypes.NUMERIC,
AS: 'age'
},
'$.coins': {
type: SchemaFieldTypes.NUMERIC,
AS: 'coins'
}
}, {
ON: 'JSON',
PREFIX: 'noderedis:users'
});
console.log({
// ✅ works: 1 result
bare: await redisClient.ft.search('idx:users', '@name:"Alice Johnson"', { DIALECT: 2 }),
// ✅ works: 1 result
withParamsNumber: await redisClient.ft.search('idx:users', '@age:[$age $age]', { DIALECT: 2, PARAMS: { age: 32 } }),
// ❌ no results
withParamsExactMatch1: await redisClient.ft.search('idx:users', '@name:"$name"', { DIALECT: 2, PARAMS: { name: 'Alice Johnson' } }),
// ❌ no results
withParamsExactMatch2: await redisClient.ft.search('idx:users', '@name:$name', { DIALECT: 2, PARAMS: { name: '"Alice Johnson"' } }),
// ✅ works: 1 result
withParamsMatch: await redisClient.ft.search('idx:users', '@name:($name)', { DIALECT: 2, PARAMS: { name: 'Alice' } }),
})
await redisClient.disconnect();
})();
Node.js Version
No response
Redis Server Version
No response
Node Redis Version
No response
Platform
No response