@@ -43,6 +43,9 @@ describe('Unit testing of the MergeWithExisting class', () => {
4343 bq : {
4444 enabled : false ,
4545 } ,
46+ sq : {
47+ enabled : false ,
48+ } ,
4649 } ,
4750 vectorIndexType : 'hnsw' ,
4851 vectorizer : {
@@ -55,7 +58,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
5558 } ;
5659
5760 it ( 'should merge a full invertedIndexUpdate with existing schema' , ( ) => {
58- const merged = MergeWithExisting . invertedIndex ( Object . assign ( { } , invertedIndex ) , {
61+ const merged = MergeWithExisting . invertedIndex ( JSON . parse ( JSON . stringify ( invertedIndex ) ) , {
5962 bm25 : {
6063 b : 0.9 ,
6164 k1 : 1.4 ,
@@ -110,7 +113,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
110113 } ;
111114
112115 it ( 'should merge a partial invertedIndexUpdate with existing schema' , ( ) => {
113- const merged = MergeWithExisting . invertedIndex ( Object . assign ( { } , invertedIndex ) , {
116+ const merged = MergeWithExisting . invertedIndex ( JSON . parse ( JSON . stringify ( invertedIndex ) ) , {
114117 bm25 : {
115118 b : 0.9 ,
116119 } ,
@@ -134,7 +137,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
134137 } ) ;
135138
136139 it ( 'should merge a no quantizer HNSW vectorIndexConfig with existing schema' , ( ) => {
137- const merged = MergeWithExisting . vectors ( Object . assign ( { } , hnswVectorConfig ) , [
140+ const merged = MergeWithExisting . vectors ( JSON . parse ( JSON . stringify ( hnswVectorConfig ) ) , [
138141 {
139142 name : 'name' ,
140143 vectorIndex : {
@@ -158,6 +161,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
158161 expect ( merged ) . toEqual ( {
159162 name : {
160163 vectorIndexConfig : {
164+ ...hnswVectorConfig . name . vectorIndexConfig ,
161165 skip : true ,
162166 cleanupIntervalSeconds : 301 ,
163167 maxConnections : 65 ,
@@ -169,20 +173,6 @@ describe('Unit testing of the MergeWithExisting class', () => {
169173 vectorCacheMaxObjects : 1000000000001 ,
170174 flatSearchCutoff : 40001 ,
171175 distance : 'euclidean' ,
172- pq : {
173- enabled : false ,
174- bitCompression : false ,
175- segments : 0 ,
176- centroids : 256 ,
177- trainingLimit : 100000 ,
178- encoder : {
179- type : 'kmeans' ,
180- distribution : 'log-normal' ,
181- } ,
182- } ,
183- bq : {
184- enabled : false ,
185- } ,
186176 } ,
187177 vectorIndexType : 'hnsw' ,
188178 vectorizer : {
@@ -196,7 +186,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
196186 } ) ;
197187
198188 it ( 'should merge a PQ quantizer HNSW vectorIndexConfig with existing schema' , ( ) => {
199- const merged = MergeWithExisting . vectors ( Object . assign ( { } , hnswVectorConfig ) , [
189+ const merged = MergeWithExisting . vectors ( JSON . parse ( JSON . stringify ( hnswVectorConfig ) ) , [
200190 {
201191 name : 'name' ,
202192 vectorIndex : {
@@ -220,17 +210,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
220210 expect ( merged ) . toEqual ( {
221211 name : {
222212 vectorIndexConfig : {
223- skip : true ,
224- cleanupIntervalSeconds : 301 ,
225- maxConnections : 65 ,
226- efConstruction : 129 ,
227- ef : - 2 ,
228- dynamicEfMin : 101 ,
229- dynamicEfMax : 501 ,
230- dynamicEfFactor : 9 ,
231- vectorCacheMaxObjects : 1000000000001 ,
232- flatSearchCutoff : 40001 ,
233- distance : 'euclidean' ,
213+ ...hnswVectorConfig . name . vectorIndexConfig ,
234214 pq : {
235215 enabled : true ,
236216 bitCompression : true ,
@@ -242,9 +222,6 @@ describe('Unit testing of the MergeWithExisting class', () => {
242222 distribution : 'normal' ,
243223 } ,
244224 } ,
245- bq : {
246- enabled : false ,
247- } ,
248225 } ,
249226 vectorIndexType : 'hnsw' ,
250227 vectorizer : {
@@ -258,7 +235,7 @@ describe('Unit testing of the MergeWithExisting class', () => {
258235 } ) ;
259236
260237 it ( 'should merge a BQ quantizer HNSW vectorIndexConfig with existing schema' , ( ) => {
261- const merged = MergeWithExisting . vectors ( Object . assign ( { } , hnswVectorConfig ) , [
238+ const merged = MergeWithExisting . vectors ( JSON . parse ( JSON . stringify ( hnswVectorConfig ) ) , [
262239 {
263240 name : 'name' ,
264241 vectorIndex : {
@@ -292,8 +269,45 @@ describe('Unit testing of the MergeWithExisting class', () => {
292269 } ) ;
293270 } ) ;
294271
272+ it ( 'should merge a SQ quantizer HNSW vectorIndexConfig with existing schema' , ( ) => {
273+ const merged = MergeWithExisting . vectors ( JSON . parse ( JSON . stringify ( hnswVectorConfig ) ) , [
274+ {
275+ name : 'name' ,
276+ vectorIndex : {
277+ name : 'hnsw' ,
278+ config : {
279+ quantizer : {
280+ type : 'sq' ,
281+ rescoreLimit : 1000 ,
282+ trainingLimit : 10000 ,
283+ } ,
284+ } ,
285+ } ,
286+ } ,
287+ ] ) ;
288+ expect ( merged ) . toEqual ( {
289+ name : {
290+ vectorIndexConfig : {
291+ ...hnswVectorConfig . name . vectorIndexConfig ,
292+ sq : {
293+ enabled : true ,
294+ rescoreLimit : 1000 ,
295+ trainingLimit : 10000 ,
296+ } ,
297+ } ,
298+ vectorIndexType : 'hnsw' ,
299+ vectorizer : {
300+ 'text2vec-contextionary' : {
301+ properties : [ 'name' ] ,
302+ vectorizeCollectionName : false ,
303+ } ,
304+ } ,
305+ } ,
306+ } ) ;
307+ } ) ;
308+
295309 it ( 'should merge a BQ quantizer Flat vectorIndexConfig with existing schema' , ( ) => {
296- const merged = MergeWithExisting . vectors ( Object . assign ( { } , flatVectorConfig ) , [
310+ const merged = MergeWithExisting . vectors ( JSON . parse ( JSON . stringify ( flatVectorConfig ) ) , [
297311 {
298312 name : 'name' ,
299313 vectorIndex : {
0 commit comments