Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2025
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
83 changes: 83 additions & 0 deletions packages/search/lib/commands/CREATE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion packages/search/lib/commands/CREATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading