|
2 | 2 | /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
3 | 3 | import { v4 } from 'uuid';
|
4 | 4 | import { WeaviateUnsupportedFeatureError } from '../../errors.js';
|
5 |
| -import weaviate, { WeaviateClient } from '../../index.js'; |
| 5 | +import weaviate, { WeaviateClient, weaviateV2 } from '../../index.js'; |
6 | 6 | import { GeoCoordinate, PhoneNumber } from '../../proto/v1/properties.js';
|
7 | 7 | import { Collection } from '../collection/index.js';
|
8 | 8 | import { CrossReference, CrossReferences, Reference } from '../references/index.js';
|
@@ -1000,3 +1000,38 @@ describe('Testing of the collection.data methods with a vector index', () => {
|
1000 | 1000 | expect(obj2?.vectors.default).toEqual([5, 6, 7, 8]);
|
1001 | 1001 | });
|
1002 | 1002 | });
|
| 1003 | + |
| 1004 | +describe('Testing of BYOV insertion with legacy vectorizer', () => { |
| 1005 | + const collectionName = 'TestBYOVEdgeCase'; |
| 1006 | + const oldClient = weaviateV2.client({ scheme: 'http', host: 'localhost:8080' }); |
| 1007 | + |
| 1008 | + beforeAll(() => |
| 1009 | + oldClient.schema |
| 1010 | + .classCreator() |
| 1011 | + .withClass({ |
| 1012 | + class: collectionName, |
| 1013 | + vectorizer: 'none', |
| 1014 | + }) |
| 1015 | + .do() |
| 1016 | + ); |
| 1017 | + |
| 1018 | + afterAll(() => oldClient.schema.classDeleter().withClassName(collectionName).do()); |
| 1019 | + |
| 1020 | + it('should insert and retrieve many vectors using the new client', async () => { |
| 1021 | + const client = await weaviate.connectToLocal(); |
| 1022 | + const collection = client.collections.get(collectionName); |
| 1023 | + await collection.data.insertMany([{ vectors: [1, 2, 3] }, { vectors: [4, 5, 6] }]); |
| 1024 | + const objects = await collection.query.fetchObjects({ includeVector: true }).then((res) => res.objects); |
| 1025 | + expect(objects.length).toEqual(2); |
| 1026 | + expect(objects[0].vectors.default).toEqual([1, 2, 3]); |
| 1027 | + expect(objects[1].vectors.default).toEqual([4, 5, 6]); |
| 1028 | + }); |
| 1029 | + |
| 1030 | + it('should insert and retrieve single vectors using the new client', async () => { |
| 1031 | + const client = await weaviate.connectToLocal(); |
| 1032 | + const collection = client.collections.get(collectionName); |
| 1033 | + const id = await collection.data.insert({ vectors: [7, 8, 9] }); |
| 1034 | + const object = await collection.query.fetchObjectById(id, { includeVector: true }); |
| 1035 | + expect(object?.vectors.default).toEqual([7, 8, 9]); |
| 1036 | + }); |
| 1037 | +}); |
0 commit comments