Skip to content

Commit 80294c0

Browse files
committed
Fix updating vector index of legacy vectorizer, comment back in missing test for it
1 parent b2dc636 commit 80294c0

File tree

2 files changed

+57
-69
lines changed

2 files changed

+57
-69
lines changed

src/collections/config/classes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class MergeWithExisting {
3838
if (update.vectorizers !== undefined) {
3939
if (Array.isArray(update.vectorizers)) {
4040
current.vectorConfig = MergeWithExisting.vectors(current.vectorConfig, update.vectorizers);
41-
} else if (supportsNamedVectors) {
41+
} else if (supportsNamedVectors && current.vectorConfig !== undefined) {
4242
const updateVectorizers = {
4343
...update.vectorizers,
4444
name: 'default',

src/collections/config/integration.test.ts

Lines changed: 56 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
22
import { WeaviateUnsupportedFeatureError } from '../../errors.js';
3-
import weaviate, { WeaviateClient } from '../../index.js';
3+
import weaviate, { WeaviateClient, weaviateV2 } from '../../index.js';
44
import { PropertyConfig, VectorIndexConfigDynamic, VectorIndexConfigHNSW } from './types/index.js';
55

66
const fail = (msg: string) => {
@@ -526,71 +526,59 @@ describe('Testing of the collection.config namespace', () => {
526526
expect(config.multiTenancy.enabled).toEqual(true);
527527
});
528528

529-
// it('should be able update the config of a collection with legacy vectors', async () => {
530-
// const collectionName = 'TestCollectionConfigUpdateLegacyVectors';
531-
// const collection = await client.collections.create({
532-
// name: collectionName,
533-
// properties: [
534-
// {
535-
// name: 'testProp',
536-
// dataType: 'text',
537-
// },
538-
// ],
539-
// vectorizer: {
540-
// name: 'none',
541-
// config: {},
542-
// },
543-
// });
544-
// const config = await collection.config
545-
// .update({
546-
// vectorizers: weaviate.reconfigure.vectorIndex.hnsw({
547-
// quantizer: weaviate.reconfigure.vectorIndex.quantizer.pq(),
548-
// ef: 4,
549-
// }),
550-
// })
551-
// .then(() => collection.config.get());
552-
553-
// expect(config.name).toEqual(collectionName);
554-
// expect(config.properties).toEqual<PropertyConfig[]>([
555-
// {
556-
// name: 'testProp',
557-
// dataType: 'text',
558-
// description: undefined,
559-
// indexSearchable: true,
560-
// indexFilterable: true,
561-
// indexInverted: false,
562-
// vectorizerConfig: undefined,
563-
// nestedProperties: undefined,
564-
// tokenization: 'word',
565-
// },
566-
// ]);
567-
// expect(config.generative).toBeUndefined();
568-
// expect(config.reranker).toBeUndefined();
569-
// expect(config.vectorizers.default.indexConfig).toEqual<VectorIndexConfigHNSW>({
570-
// skip: false,
571-
// cleanupIntervalSeconds: 300,
572-
// maxConnections: 64,
573-
// efConstruction: 128,
574-
// ef: 4,
575-
// dynamicEfMin: 100,
576-
// dynamicEfMax: 500,
577-
// dynamicEfFactor: 8,
578-
// vectorCacheMaxObjects: 1000000000000,
579-
// flatSearchCutoff: 40000,
580-
// distance: 'cosine',
581-
// quantizer: {
582-
// bitCompression: false,
583-
// segments: 0,
584-
// centroids: 256,
585-
// trainingLimit: 100000,
586-
// encoder: {
587-
// type: 'kmeans',
588-
// distribution: 'log-normal',
589-
// },
590-
// type: 'pq',
591-
// },
592-
// });
593-
// expect(config.vectorizers.default.indexType).toEqual('hnsw');
594-
// expect(config.vectorizers.default.vectorizer.name).toEqual('none');
595-
// });
529+
it('should be able update the config of a collection with legacy vectors', async () => {
530+
const clientV2 = weaviateV2.client({
531+
host: 'http://localhost:8080',
532+
});
533+
const collectionName = 'TestCollectionConfigUpdateLegacyVectors';
534+
await clientV2.schema
535+
.classCreator()
536+
.withClass({
537+
class: collectionName,
538+
vectorizer: 'none',
539+
})
540+
.do();
541+
const collection = client.collections.get(collectionName);
542+
const config = await collection.config
543+
.update({
544+
vectorizers: weaviate.reconfigure.vectorizer.update({
545+
vectorIndexConfig: weaviate.reconfigure.vectorIndex.hnsw({
546+
quantizer: weaviate.reconfigure.vectorIndex.quantizer.pq(),
547+
ef: 4,
548+
}),
549+
}),
550+
})
551+
.then(() => collection.config.get());
552+
553+
expect(config.name).toEqual(collectionName);
554+
expect(config.generative).toBeUndefined();
555+
expect(config.reranker).toBeUndefined();
556+
expect(config.vectorizers.default.indexConfig).toEqual<VectorIndexConfigHNSW>({
557+
skip: false,
558+
cleanupIntervalSeconds: 300,
559+
maxConnections: (await client.getWeaviateVersion().then((ver) => ver.isLowerThan(1, 26, 0))) ? 64 : 32,
560+
efConstruction: 128,
561+
ef: 4,
562+
dynamicEfMin: 100,
563+
dynamicEfMax: 500,
564+
dynamicEfFactor: 8,
565+
vectorCacheMaxObjects: 1000000000000,
566+
flatSearchCutoff: 40000,
567+
distance: 'cosine',
568+
type: 'hnsw',
569+
quantizer: {
570+
bitCompression: false,
571+
segments: 0,
572+
centroids: 256,
573+
trainingLimit: 100000,
574+
encoder: {
575+
type: 'kmeans',
576+
distribution: 'log-normal',
577+
},
578+
type: 'pq',
579+
},
580+
});
581+
expect(config.vectorizers.default.indexType).toEqual('hnsw');
582+
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
583+
});
596584
});

0 commit comments

Comments
 (0)