@@ -5,15 +5,12 @@ import {
55 GeoCoordinate ,
66 PQConfig ,
77 PhoneNumber ,
8+ PropertyConfig ,
89 Text2VecContextionaryConfig ,
910 Text2VecOpenAIConfig ,
1011 VectorIndexConfigHNSW ,
1112} from './types/index' ;
1213
13- const fail = ( msg : string ) => {
14- throw new Error ( msg ) ;
15- } ;
16-
1714describe ( 'Testing of the collections.create method' , ( ) => {
1815 let cluster : WeaviateClient ;
1916 let contextionary : WeaviateClient ;
@@ -34,6 +31,14 @@ describe('Testing of the collections.create method', () => {
3431 } ) ;
3532 } ) ;
3633
34+ afterAll ( ( ) =>
35+ Promise . all ( [
36+ cluster . collections . deleteAll ( ) ,
37+ contextionary . collections . deleteAll ( ) ,
38+ openai . collections . deleteAll ( ) ,
39+ ] )
40+ ) ;
41+
3742 it ( 'should be able to create a simple collection with a generic' , async ( ) => {
3843 const collectionName = 'TestCollectionSimpleGeneric' ;
3944 type TestCollectionSimple = {
@@ -57,8 +62,6 @@ describe('Testing of the collections.create method', () => {
5762 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
5863 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
5964 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
60-
61- await contextionary . collections . delete ( collectionName ) ;
6265 } ) ;
6366
6467 it ( 'should be able to create a simple collection without a generic' , async ( ) => {
@@ -81,8 +84,79 @@ describe('Testing of the collections.create method', () => {
8184 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
8285 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
8386 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
87+ } ) ;
8488
85- await contextionary . collections . delete ( collectionName ) ;
89+ it ( 'should be able to create a collection with one fully customised text property' , ( ) => {
90+ return contextionary . collections
91+ . create ( {
92+ name : 'TestCollectionTextProperty' ,
93+ properties : [
94+ {
95+ name : 'text' ,
96+ dataType : 'text' ,
97+ indexFilterable : true ,
98+ indexSearchable : true ,
99+ skipVectorization : true ,
100+ tokenization : 'field' ,
101+ vectorizePropertyName : true ,
102+ } ,
103+ ] ,
104+ vectorizers : weaviate . configure . vectorizer . text2VecContextionary ( ) ,
105+ } )
106+ . then ( ( collection ) => collection . config . get ( ) )
107+ . then ( ( config ) =>
108+ expect ( config . properties [ 0 ] ) . toEqual < PropertyConfig > ( {
109+ name : 'text' ,
110+ dataType : 'text' ,
111+ indexFilterable : true ,
112+ indexInverted : false ,
113+ indexRangeFilters : false ,
114+ indexSearchable : true ,
115+ tokenization : 'field' ,
116+ vectorizerConfig : {
117+ 'text2vec-contextionary' : {
118+ skip : true ,
119+ vectorizePropertyName : true ,
120+ } ,
121+ } ,
122+ } )
123+ ) ;
124+ } ) ;
125+
126+ it ( 'should be able to create a collection with one fully customised int property' , ( ) => {
127+ return contextionary . collections
128+ . create ( {
129+ name : 'TestCollectionIntProperty' ,
130+ properties : [
131+ {
132+ name : 'int' ,
133+ dataType : 'int' ,
134+ indexFilterable : true ,
135+ indexRangeFilters : true ,
136+ skipVectorization : true ,
137+ vectorizePropertyName : true ,
138+ } ,
139+ ] ,
140+ vectorizers : weaviate . configure . vectorizer . text2VecContextionary ( ) ,
141+ } )
142+ . then ( ( collection ) => collection . config . get ( ) )
143+ . then ( async ( config ) =>
144+ expect ( config . properties [ 0 ] ) . toEqual < PropertyConfig > ( {
145+ name : 'int' ,
146+ dataType : 'int' ,
147+ indexFilterable : true ,
148+ indexInverted : false ,
149+ indexRangeFilters : await contextionary . getWeaviateVersion ( ) . then ( ( ver ) => ver . isAtLeast ( 1 , 26 , 0 ) ) ,
150+ indexSearchable : false ,
151+ tokenization : 'none' ,
152+ vectorizerConfig : {
153+ 'text2vec-contextionary' : {
154+ skip : true ,
155+ vectorizePropertyName : true ,
156+ } ,
157+ } ,
158+ } )
159+ ) ;
86160 } ) ;
87161
88162 it ( 'should be able to create a simple collection without a generic and no properties' , async ( ) => {
@@ -97,8 +171,6 @@ describe('Testing of the collections.create method', () => {
97171 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
98172 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
99173 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
100-
101- await contextionary . collections . delete ( collectionName ) ;
102174 } ) ;
103175
104176 it ( 'should be able to create a simple collection without a generic using a schema var' , async ( ) => {
@@ -123,8 +195,6 @@ describe('Testing of the collections.create method', () => {
123195 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
124196 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
125197 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
126-
127- await contextionary . collections . delete ( collectionName ) ;
128198 } ) ;
129199
130200 it ( 'should be able to create a simple collection with a generic using a schema var with const' , async ( ) => {
@@ -152,8 +222,6 @@ describe('Testing of the collections.create method', () => {
152222 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
153223 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
154224 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
155-
156- await contextionary . collections . delete ( collectionName ) ;
157225 } ) ;
158226
159227 it ( 'should be able to create a simple collection with a generic using a schema var with type' , async ( ) => {
@@ -181,8 +249,6 @@ describe('Testing of the collections.create method', () => {
181249 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
182250 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
183251 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
184-
185- await contextionary . collections . delete ( collectionName ) ;
186252 } ) ;
187253
188254 it ( 'should be able to create a nested collection' , async ( ) => {
@@ -219,8 +285,6 @@ describe('Testing of the collections.create method', () => {
219285 expect ( response . vectorizers . default . indexConfig ) . toBeDefined ( ) ;
220286 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
221287 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
222-
223- await contextionary . collections . delete ( collectionName ) ;
224288 } ) ;
225289
226290 it ( 'should be able to create a collection with generic properties' , ( ) => {
@@ -248,7 +312,7 @@ describe('Testing of the collections.create method', () => {
248312 phoneNumber : PhoneNumber ;
249313 } ;
250314
251- cluster . collections . create < TestCollectionGenericProperties , 'TestCollectionGenericProperties' > ( {
315+ return cluster . collections . create < TestCollectionGenericProperties , 'TestCollectionGenericProperties' > ( {
252316 name : collectionName ,
253317 properties : [
254318 {
@@ -539,8 +603,6 @@ describe('Testing of the collections.create method', () => {
539603 expect ( response . vectorizers . default . indexType ) . toEqual ( 'hnsw' ) ;
540604
541605 expect ( response . vectorizers . default . vectorizer . name ) . toEqual ( 'text2vec-contextionary' ) ;
542-
543- await cluster . collections . delete ( collectionName ) ;
544606 } ) ;
545607
546608 it ( 'should be able to create a collection with the contextionary vectorizer using configure.vectorizer' , async ( ) => {
@@ -569,8 +631,6 @@ describe('Testing of the collections.create method', () => {
569631 expect (
570632 ( response . vectorizers . default . vectorizer . config as Text2VecContextionaryConfig ) . vectorizeCollectionName
571633 ) . toEqual ( true ) ;
572-
573- await contextionary . collections . delete ( collectionName ) ;
574634 } ) ;
575635
576636 it ( 'should be able to create a collection with an openai vectorizer with configure.vectorizer' , async ( ) => {
@@ -599,8 +659,6 @@ describe('Testing of the collections.create method', () => {
599659 expect (
600660 ( response . vectorizers . default . vectorizer . config as Text2VecOpenAIConfig ) . vectorizeCollectionName
601661 ) . toEqual ( true ) ;
602-
603- await openai . collections . delete ( collectionName ) ;
604662 } ) ;
605663
606664 it ( 'should be able to create a collection with the openai generative with configure.Generative' , async ( ) => {
@@ -626,7 +684,5 @@ describe('Testing of the collections.create method', () => {
626684 name : 'generative-openai' ,
627685 config : { } ,
628686 } ) ;
629-
630- await openai . collections . delete ( collectionName ) ;
631687 } ) ;
632688} ) ;
0 commit comments