@@ -186,15 +186,18 @@ export class MergeWithExisting {
186186    current : WeaviateVectorIndexConfig , 
187187    update : VectorIndexConfigHNSWUpdate 
188188  ) : WeaviateVectorIndexConfig  { 
189+     const  hasOtherQuantizerAlready  =  ( quantizer : string )  => 
190+       [ 'pq' ,  'bq' ,  'sq' ,  'rq' ] . some ( 
191+         ( q )  =>  q  !==  quantizer  &&  ( current ?. [ q  as  keyof  WeaviateVectorIndexConfig ]  as  any ) ?. enabled 
192+       ) ; 
189193    if  ( 
190-       ( QuantizerGuards . isBQUpdate ( update . quantizer )  && 
191-         ( ( ( current ?. pq  as  any )  ||  { } ) . enabled  ||  ( ( current ?. sq  as  any )  ||  { } ) . enabled ) )  || 
192-       ( QuantizerGuards . isPQUpdate ( update . quantizer )  && 
193-         ( ( ( current ?. bq  as  any )  ||  { } ) . enabled  ||  ( ( current ?. sq  as  any )  ||  { } ) . enabled ) )  || 
194-       ( QuantizerGuards . isSQUpdate ( update . quantizer )  && 
195-         ( ( ( current ?. pq  as  any )  ||  { } ) . enabled  ||  ( ( current ?. bq  as  any )  ||  { } ) . enabled ) ) 
196-     ) 
194+       ( QuantizerGuards . isBQUpdate ( update . quantizer )  &&  hasOtherQuantizerAlready ( 'bq' ) )  || 
195+       ( QuantizerGuards . isPQUpdate ( update . quantizer )  &&  hasOtherQuantizerAlready ( 'pq' ) )  || 
196+       ( QuantizerGuards . isSQUpdate ( update . quantizer )  &&  hasOtherQuantizerAlready ( 'sq' ) )  || 
197+       ( QuantizerGuards . isRQUpdate ( update . quantizer )  &&  hasOtherQuantizerAlready ( 'rq' ) ) 
198+     )  { 
197199      throw  new  WeaviateInvalidInputError ( `Cannot update the quantizer type of an enabled vector index.` ) ; 
200+     } 
198201    const  {  quantizer,  ...rest  }  =  update ; 
199202    const  merged : WeaviateVectorIndexConfig  =  {  ...current ,  ...rest  } ; 
200203    if  ( QuantizerGuards . isBQUpdate ( quantizer ) )  { 
@@ -209,6 +212,10 @@ export class MergeWithExisting {
209212      const  {  type,  ...quant  }  =  quantizer ; 
210213      merged . sq  =  {  ...current ! . sq ! ,  ...quant ,  enabled : true  } ; 
211214    } 
215+     if  ( QuantizerGuards . isRQUpdate ( quantizer ) )  { 
216+       const  {  type,  ...quant  }  =  quantizer ; 
217+       merged . rq  =  {  ...current ! . rq ! ,  ...quant ,  enabled : true  } ; 
218+     } 
212219    return  merged ; 
213220  } 
214221} 
0 commit comments