Skip to content

Commit 40d7841

Browse files
committed
feat: allow creating single named vector
1 parent 7523c5c commit 40d7841

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/collections/configure/types/vectorizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export type VectorConfigUpdate<N extends string | undefined, I extends VectorInd
5555
};
5656

5757
export type VectorizersConfigCreate<T> =
58-
| VectorConfigCreate<PrimitiveKeys<T>, undefined, VectorIndexType, Vectorizer>
58+
| VectorConfigCreate<PrimitiveKeys<T>, string | undefined, VectorIndexType, Vectorizer>
5959
| VectorConfigCreate<PrimitiveKeys<T>, string, VectorIndexType, Vectorizer>[];
6060

6161
export type VectorizersConfigAdd<T> =

src/collections/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const collections = (connection: Connection, dbVersionSupport: DbVersionSupport)
147147
throw new WeaviateUnsupportedFeatureError(supportsNamedVectors.message);
148148
}
149149
const configs = config.vectorizers
150-
? makeLegacyVectorizer(config.vectorizers)
150+
? makeLegacyVectorizer({ ...config.vectorizers, name: undefined })
151151
: {
152152
vectorizer: undefined,
153153
moduleConfig: undefined,

src/collections/integration.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,20 @@ describe('Testing of the collections.create method', () => {
174174
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
175175
});
176176

177+
it('should be able to create a collection with 1 custom named vector', async () => {
178+
const collectionName = 'TestCollectionSingleCustomNamedVector';
179+
const response = await contextionary.collections
180+
.create({
181+
name: collectionName,
182+
vectorizers: weaviate.configure.vectorizer.none({ name: 'custom' }),
183+
})
184+
.then(() => contextionary.collections.use(collectionName).config.get());
185+
expect(response.name).toEqual(collectionName);
186+
expect(response.properties?.length).toEqual(0);
187+
expect(response.vectorizers.custom.indexConfig).toBeDefined();
188+
expect(response.vectorizers.custom.indexType).toEqual('hnsw');
189+
});
190+
177191
it('should be able to create a simple collection without a generic using a schema var', async () => {
178192
const collectionName = 'TestCollectionSimpleNonGenericVar';
179193
const schema = {

0 commit comments

Comments
 (0)