1
0
mirror of https://github.com/redis/node-redis.git synced 2025-09-11 18:50:46 +03:00

feat(integer 8 vector support): Changed ft create vector types to union, added support for int8/uint8 (#2911)

* [CAE-827] Changed ft create vector types to union, added support for int8/uint8

* [CAE-827] Moved test cases
This commit is contained in:
Hristo Temelski
2025-03-21 11:43:10 +02:00
committed by GitHub
parent 6c5a3fd0c0
commit d64072da95
2 changed files with 84 additions and 1 deletions

View File

@@ -473,4 +473,87 @@ describe('FT.CREATE', () => {
'OK'
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.ft.create vector types big floats', async client => {
assert.equal(
await client.ft.create("index_float32", {
field: {
ALGORITHM: "FLAT",
TYPE: "FLOAT32",
DIM: 1,
DISTANCE_METRIC: 'COSINE',
type: 'VECTOR'
},
}),
"OK"
);
assert.equal(
await client.ft.create("index_float64", {
field: {
ALGORITHM: "FLAT",
TYPE: "FLOAT64",
DIM: 1,
DISTANCE_METRIC: 'COSINE',
type: 'VECTOR'
},
}),
"OK"
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'client.ft.create vector types small floats and ints', async client => {
assert.equal(
await client.ft.create("index_float16", {
field: {
ALGORITHM: "FLAT",
TYPE: "FLOAT16",
DIM: 1,
DISTANCE_METRIC: 'COSINE',
type: 'VECTOR'
},
}),
"OK"
);
assert.equal(
await client.ft.create("index_bloat16", {
field: {
ALGORITHM: "FLAT",
TYPE: "BFLOAT16",
DIM: 1,
DISTANCE_METRIC: 'COSINE',
type: 'VECTOR'
},
}),
"OK"
);
assert.equal(
await client.ft.create("index_int8", {
field: {
ALGORITHM: "FLAT",
TYPE: "INT8",
DIM: 1,
DISTANCE_METRIC: 'COSINE',
type: 'VECTOR'
},
}),
"OK"
);
assert.equal(
await client.ft.create("index_uint8", {
field: {
ALGORITHM: "FLAT",
TYPE: "UINT8",
DIM: 1,
DISTANCE_METRIC: 'COSINE',
type: 'VECTOR'
},
}),
"OK"
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -61,7 +61,7 @@ export type SchemaVectorFieldAlgorithm = typeof SCHEMA_VECTOR_FIELD_ALGORITHM[ke
interface SchemaVectorField extends SchemaField<typeof SCHEMA_FIELD_TYPE['VECTOR']> {
ALGORITHM: SchemaVectorFieldAlgorithm;
TYPE: string;
TYPE: 'FLOAT32' | 'FLOAT64' | 'BFLOAT16' | 'FLOAT16' | 'INT8' | 'UINT8';
DIM: number;
DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
INITIAL_CAP?: number;