Skip to content

Fix missing QuantizerGuard.isSQCreate call when creating collections #302

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 7 commits into from
Jun 10, 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
1,418 changes: 820 additions & 598 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"weaviate"
],
"author": "Weaviate",
"license": "BSD-3-Clause",
"license": "BSD 3-Clause",
"bugs": {
"url": "https://github.com/weaviate/typescript-client/issues"
},
Expand Down
47 changes: 37 additions & 10 deletions src/collections/config/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('Testing of the collection.config namespace', () => {
expect(config.vectorizers.title.vectorizer.name).toEqual('text2vec-contextionary');
});

it('should be able to get the config of a collection with HNSW+PQ', async () => {
it('should be able to get the config of a collection with hnsw-pq', async () => {
const collectionName = 'TestCollectionConfigGetHNSWPlusPQ';
const collection = await client.collections.create({
name: collectionName,
Expand All @@ -204,12 +204,13 @@ describe('Testing of the collection.config namespace', () => {
expect(config.reranker).toBeUndefined();
expect(vectorIndexConfig).toBeDefined();
expect(vectorIndexConfig.quantizer).toBeDefined();
expect(vectorIndexConfig.quantizer?.type).toEqual('pq');
expect(config.vectorizers.default.indexType).toEqual('hnsw');
expect(config.vectorizers.default.properties).toBeUndefined();
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
});

it('should be able to get the config of a collection with HNSW+BQ', async () => {
it('should be able to get the config of a collection with hnsw-bq', async () => {
const collectionName = 'TestCollectionConfigGetHNSWPlusBQ';
const query = () =>
client.collections.create({
Expand All @@ -232,12 +233,37 @@ describe('Testing of the collection.config namespace', () => {
expect(config.reranker).toBeUndefined();
expect(vectorIndexConfig).toBeDefined();
expect(vectorIndexConfig.quantizer).toBeDefined();
expect(vectorIndexConfig.quantizer?.type).toEqual('bq');
expect(config.vectorizers.default.indexType).toEqual('hnsw');
expect(config.vectorizers.default.properties).toBeUndefined();
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
});

it('should be able to get the config of a collection with flat+BQ', async () => {
requireAtLeast(1, 26, 0).it('should be able to get the config of a collection with hnsw-sq', async () => {
const collectionName = 'TestCollectionConfigGetHNSWPlusSQ';
const collection = await client.collections.create({
name: collectionName,
vectorizers: weaviate.configure.vectorizer.none({
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({
quantizer: weaviate.configure.vectorIndex.quantizer.sq(),
}),
}),
});
const config = await collection.config.get();

const vectorIndexConfig = config.vectorizers.default.indexConfig as VectorIndexConfigHNSW;
expect(config.name).toEqual(collectionName);
expect(config.generative).toBeUndefined();
expect(config.reranker).toBeUndefined();
expect(vectorIndexConfig).toBeDefined();
expect(vectorIndexConfig.quantizer).toBeDefined();
expect(vectorIndexConfig.quantizer?.type).toEqual('sq');
expect(config.vectorizers.default.indexType).toEqual('hnsw');
expect(config.vectorizers.default.properties).toBeUndefined();
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
});

it('should be able to get the config of a collection with flat-bq', async () => {
const collectionName = 'TestCollectionConfigGetFlatPlusBQ';
const collection = await client.collections.create({
name: collectionName,
Expand All @@ -255,12 +281,13 @@ describe('Testing of the collection.config namespace', () => {
expect(config.reranker).toBeUndefined();
expect(vectorIndexConfig).toBeDefined();
expect(vectorIndexConfig.quantizer).toBeDefined();
expect(vectorIndexConfig.quantizer?.type).toEqual('bq');
expect(config.vectorizers.default.indexType).toEqual('flat');
expect(config.vectorizers.default.properties).toBeUndefined();
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
});

it('should be able to get the config of a single-vector collection with dynamic+BQ', async () => {
it('should be able to get the config of a single-vector collection with dynamic hnsw-pq & flat-bq', async () => {
const asyncIndexing = await weaviate.connectToLocal({ port: 8078, grpcPort: 50049 }); // need async indexing for dynamic vectorizer
const collectionName = 'TestSVCollectionConfigGetDynamicPlusBQ';
await asyncIndexing.collections.delete(collectionName);
Expand Down Expand Up @@ -292,14 +319,16 @@ describe('Testing of the collection.config namespace', () => {
expect((vectorIndexConfig as any).quantizer).toBeUndefined();
expect(vectorIndexConfig.hnsw).toBeDefined();
expect(vectorIndexConfig.hnsw.quantizer).toBeDefined();
expect(vectorIndexConfig.hnsw.quantizer?.type).toEqual('pq');
expect(vectorIndexConfig.flat).toBeDefined();
expect(vectorIndexConfig.flat.quantizer).toBeDefined();
expect(vectorIndexConfig.flat.quantizer?.type).toEqual('bq');
expect(config.vectorizers.default.indexType).toEqual('dynamic');
expect(config.vectorizers.default.properties).toBeUndefined();
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
});

it('should be able to get the config of a multi-vector collection with dynamic+BQ', async () => {
it('should be able to get the config of a multi-vector collection with dynamic hnsw-pq & flat-bq', async () => {
const asyncIndexing = await weaviate.connectToLocal({ port: 8078, grpcPort: 50049 }); // need async indexing for dynamic vectorizer
const collectionName = 'TestMVCollectionConfigGetDynamicPlusBQ';
await asyncIndexing.collections.delete(collectionName);
Expand Down Expand Up @@ -331,8 +360,10 @@ describe('Testing of the collection.config namespace', () => {
expect((vectorIndexConfig as any).quantizer).toBeUndefined();
expect(vectorIndexConfig.hnsw).toBeDefined();
expect(vectorIndexConfig.hnsw.quantizer).toBeDefined();
expect(vectorIndexConfig.hnsw.quantizer?.type).toEqual('pq');
expect(vectorIndexConfig.flat).toBeDefined();
expect(vectorIndexConfig.flat.quantizer).toBeDefined();
expect(vectorIndexConfig.flat.quantizer?.type).toEqual('bq');
expect(config.vectorizers.default.indexType).toEqual('dynamic');
expect(config.vectorizers.default.properties).toBeUndefined();
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
Expand Down Expand Up @@ -387,11 +418,7 @@ describe('Testing of the collection.config namespace', () => {
]);
});

requireAtLeast(
1,
31,
0
)('Mutable named vectors', () => {
requireAtLeast(1, 31, 0).describe('Mutable named vectors', () => {
it('should be able to add named vectors to a collection', async () => {
const collectionName = 'TestCollectionConfigAddVector' as const;
const collection = await client.collections.create({
Expand Down
10 changes: 10 additions & 0 deletions src/collections/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ export const parseVectorIndex = (module: ModuleConfig<VectorIndexType, VectorInd
},
};
}
if (QuantizerGuards.isSQCreate(quantizer)) {
const { type, ...quant } = quantizer;
return {
...conf,
sq: {
...quant,
enabled: true,
},
};
}
};

export const parseVectorizerConfig = (config?: VectorizerConfig): any => {
Expand Down
6 changes: 1 addition & 5 deletions src/collections/query/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ describe('Testing of the collection.query methods with a simple collection', ()
expect(ret.objects[0].uuid).toEqual(id);
});

requireAtLeast(
1,
31,
0
)('bm25 search operator (minimum_should_match)', () => {
requireAtLeast(1, 31, 0).describe('bm25 search operator (minimum_should_match)', () => {
it('should query with bm25 + operator', async () => {
const ret = await collection.query.bm25('carrot', {
limit: 1,
Expand Down
12 changes: 2 additions & 10 deletions src/roles/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,7 @@ const testCases: TestCase[] = [
},
];

requireAtLeast(
1,
29,
0
)('Integration testing of the roles namespace', () => {
requireAtLeast(1, 29, 0).describe('Integration testing of the roles namespace', () => {
let client: WeaviateClient;

beforeAll(async () => {
Expand Down Expand Up @@ -317,11 +313,7 @@ requireAtLeast(
expect(exists).toBeFalsy();
});

requireAtLeast(
1,
30,
0
)('namespaced users', () => {
requireAtLeast(1, 30, 0).describe('namespaced users', () => {
it('retrieves assigned users with/without namespace', async () => {
await client.roles.create('landlord', {
collection: 'Buildings',
Expand Down
18 changes: 3 additions & 15 deletions src/users/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { requireAtLeast } from '../../test/version.js';
import { WeaviateUserTypeDB } from '../openapi/types.js';
import { GetUserOptions, UserDB } from './types.js';

requireAtLeast(
1,
29,
0
)('Integration testing of the users namespace', () => {
requireAtLeast(1, 29, 0).describe('Integration testing of the users namespace', () => {
const makeClient = (key: string) =>
weaviate.connectToLocal({
port: 8091,
Expand Down Expand Up @@ -62,11 +58,7 @@ requireAtLeast(
expect(roles.test).toBeUndefined();
});

requireAtLeast(
1,
30,
0
)('dynamic user management', () => {
requireAtLeast(1, 30, 0).describe('dynamic user management', () => {
/** List dynamic DB users. */
const listDBUsers = (c: WeaviateClient, opts?: GetUserOptions) =>
c.users.db.listAll(opts).then((all) => all.filter((u) => u.userType == 'db_user'));
Expand Down Expand Up @@ -172,11 +164,7 @@ requireAtLeast(
expect(roles.Permissioner.nodesPermissions).toHaveLength(1);
});

requireAtLeast(
1,
30,
1
)('additional DUM features', () => {
requireAtLeast(1, 30, 1).describe('additional DUM features', () => {
it('should be able to fetch additional user info', async () => {
const admin = await makeClient('admin-key');
const timKey = await admin.users.db.create('timely-tim');
Expand Down
10 changes: 9 additions & 1 deletion test/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ const version = DbVersion.fromString(`v${process.env.WEAVIATE_VERSION!}`);

/** Run the suite / test only for Weaviate version above this. */
export const requireAtLeast = (...semver: [...Parameters<DbVersion['isAtLeast']>]) =>
version.isAtLeast(...semver) ? describe : describe.skip;
version.isAtLeast(...semver)
? {
describe,
it,
}
: {
describe: describe.skip,
it: it.skip,
};