You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
feat: add EPSILON parameter support to VSIM command (#3041)
This commit is contained in:
@@ -31,14 +31,15 @@ describe('VSIM', () => {
|
||||
FILTER: '.price > 20',
|
||||
'FILTER-EF': 50,
|
||||
TRUTH: true,
|
||||
NOTHREAD: true
|
||||
NOTHREAD: true,
|
||||
EPSILON: 0.1
|
||||
});
|
||||
assert.deepEqual(
|
||||
parser.redisArgs,
|
||||
[
|
||||
'VSIM', 'key', 'ELE', 'element',
|
||||
'COUNT', '5', 'EF', '100', 'FILTER', '.price > 20',
|
||||
'FILTER-EF', '50', 'TRUTH', 'NOTHREAD'
|
||||
'VSIM', 'key', 'ELE', 'element', 'COUNT', '5',
|
||||
'EPSILON', '0.1', 'EF', '100', 'FILTER', '.price > 20',
|
||||
'FILTER-EF', '50', 'TRUTH', 'NOTHREAD',
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -56,6 +57,27 @@ describe('VSIM', () => {
|
||||
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
|
||||
});
|
||||
|
||||
|
||||
testUtils.testAll('vSim with options', async client => {
|
||||
await client.vAdd('key', [1.0, 2.0, 3.0], 'element1');
|
||||
await client.vAdd('key', [1.1, 2.1, 3.1], 'element2');
|
||||
|
||||
const result = await client.vSim('key', 'element1', {
|
||||
EPSILON: 0.1,
|
||||
COUNT: 1,
|
||||
EF: 100,
|
||||
FILTER: '.year == 8',
|
||||
'FILTER-EF': 50,
|
||||
TRUTH: true,
|
||||
NOTHREAD: true
|
||||
});
|
||||
|
||||
assert.ok(Array.isArray(result));
|
||||
}, {
|
||||
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
|
||||
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
|
||||
});
|
||||
|
||||
testUtils.testWithClient('vSim with RESP3', async client => {
|
||||
await client.vAdd('resp3-key', [1.0, 2.0, 3.0], 'element1');
|
||||
await client.vAdd('resp3-key', [1.1, 2.1, 3.1], 'element2');
|
||||
|
@@ -4,6 +4,7 @@ import { transformDoubleArgument } from './generic-transformers';
|
||||
|
||||
export interface VSimOptions {
|
||||
COUNT?: number;
|
||||
EPSILON?: number;
|
||||
EF?: number;
|
||||
FILTER?: string;
|
||||
'FILTER-EF'?: number;
|
||||
@@ -44,6 +45,10 @@ export default {
|
||||
parser.push('COUNT', options.COUNT.toString());
|
||||
}
|
||||
|
||||
if (options?.EPSILON !== undefined) {
|
||||
parser.push('EPSILON', options.EPSILON.toString());
|
||||
}
|
||||
|
||||
if (options?.EF !== undefined) {
|
||||
parser.push('EF', options.EF.toString());
|
||||
}
|
||||
|
Reference in New Issue
Block a user