Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions packages/client/lib/commands/VSIM.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
);
});
Expand All @@ -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');
Expand Down
5 changes: 5 additions & 0 deletions packages/client/lib/commands/VSIM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { transformDoubleArgument } from './generic-transformers';

export interface VSimOptions {
COUNT?: number;
EPSILON?: number;
EF?: number;
FILTER?: string;
'FILTER-EF'?: number;
Expand Down Expand Up @@ -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());
}
Expand Down
Loading