|
1 | 1 | /* eslint-disable @typescript-eslint/no-non-null-assertion */
|
2 | 2 | import { WeaviateUnsupportedFeatureError } from '../../errors.js';
|
3 |
| -import weaviate, { WeaviateClient } from '../../index.js'; |
| 3 | +import weaviate, { WeaviateClient, weaviateV2 } from '../../index.js'; |
4 | 4 | import { PropertyConfig, VectorIndexConfigDynamic, VectorIndexConfigHNSW } from './types/index.js';
|
5 | 5 |
|
6 | 6 | const fail = (msg: string) => {
|
@@ -526,71 +526,59 @@ describe('Testing of the collection.config namespace', () => {
|
526 | 526 | expect(config.multiTenancy.enabled).toEqual(true);
|
527 | 527 | });
|
528 | 528 |
|
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 | + }); |
596 | 584 | });
|
0 commit comments