Skip to content

Commit d64072d

Browse files
authored
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
1 parent 6c5a3fd commit d64072d

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

packages/search/lib/commands/CREATE.spec.ts

+83
Original file line numberDiff line numberDiff line change
@@ -473,4 +473,87 @@ describe('FT.CREATE', () => {
473473
'OK'
474474
);
475475
}, GLOBAL.SERVERS.OPEN);
476+
477+
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.ft.create vector types big floats', async client => {
478+
assert.equal(
479+
await client.ft.create("index_float32", {
480+
field: {
481+
ALGORITHM: "FLAT",
482+
TYPE: "FLOAT32",
483+
DIM: 1,
484+
DISTANCE_METRIC: 'COSINE',
485+
type: 'VECTOR'
486+
},
487+
}),
488+
"OK"
489+
);
490+
491+
assert.equal(
492+
await client.ft.create("index_float64", {
493+
field: {
494+
ALGORITHM: "FLAT",
495+
TYPE: "FLOAT64",
496+
DIM: 1,
497+
DISTANCE_METRIC: 'COSINE',
498+
type: 'VECTOR'
499+
},
500+
}),
501+
"OK"
502+
);
503+
}, GLOBAL.SERVERS.OPEN);
504+
505+
506+
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'client.ft.create vector types small floats and ints', async client => {
507+
assert.equal(
508+
await client.ft.create("index_float16", {
509+
field: {
510+
ALGORITHM: "FLAT",
511+
TYPE: "FLOAT16",
512+
DIM: 1,
513+
DISTANCE_METRIC: 'COSINE',
514+
type: 'VECTOR'
515+
},
516+
}),
517+
"OK"
518+
);
519+
520+
assert.equal(
521+
await client.ft.create("index_bloat16", {
522+
field: {
523+
ALGORITHM: "FLAT",
524+
TYPE: "BFLOAT16",
525+
DIM: 1,
526+
DISTANCE_METRIC: 'COSINE',
527+
type: 'VECTOR'
528+
},
529+
}),
530+
"OK"
531+
);
532+
533+
assert.equal(
534+
await client.ft.create("index_int8", {
535+
field: {
536+
ALGORITHM: "FLAT",
537+
TYPE: "INT8",
538+
DIM: 1,
539+
DISTANCE_METRIC: 'COSINE',
540+
type: 'VECTOR'
541+
},
542+
}),
543+
"OK"
544+
);
545+
546+
assert.equal(
547+
await client.ft.create("index_uint8", {
548+
field: {
549+
ALGORITHM: "FLAT",
550+
TYPE: "UINT8",
551+
DIM: 1,
552+
DISTANCE_METRIC: 'COSINE',
553+
type: 'VECTOR'
554+
},
555+
}),
556+
"OK"
557+
);
558+
}, GLOBAL.SERVERS.OPEN);
476559
});

packages/search/lib/commands/CREATE.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export type SchemaVectorFieldAlgorithm = typeof SCHEMA_VECTOR_FIELD_ALGORITHM[ke
6161

6262
interface SchemaVectorField extends SchemaField<typeof SCHEMA_FIELD_TYPE['VECTOR']> {
6363
ALGORITHM: SchemaVectorFieldAlgorithm;
64-
TYPE: string;
64+
TYPE: 'FLOAT32' | 'FLOAT64' | 'BFLOAT16' | 'FLOAT16' | 'INT8' | 'UINT8';
6565
DIM: number;
6666
DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
6767
INITIAL_CAP?: number;

0 commit comments

Comments
 (0)