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 1 commit
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
41 changes: 36 additions & 5 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 () => {
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
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
4 changes: 2 additions & 2 deletions src/collections/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export type {
IsPrimitiveField,
IsWeaviateField,
NestedKeys,
NonRefKeys,
NonReferenceInputs,
NonRefKeys,
PrimitiveKeys,
QueryNested,
QueryProperty,
QueryReference,
RefKeys,
ReferenceInput,
ReferenceInputs,
RefKeys,
} from './internal.js';
export * from './query.js';

Expand Down
Loading