@@ -1547,8 +1547,13 @@ impl Schema {
15471547 if vector_index. enabled {
15481548 return false ;
15491549 }
1550+ if !is_embedding_function_default ( & vector_index. config . embedding_function ) {
1551+ return false ;
1552+ }
1553+ if !is_space_default ( & vector_index. config . space ) {
1554+ return false ;
1555+ }
15501556 // Check that the config has default structure
1551- // We allow space and embedding_function to vary, but check structure
15521557 if vector_index. config . source_key . is_some ( ) {
15531558 return false ;
15541559 }
@@ -1613,6 +1618,9 @@ impl Schema {
16131618 if !vector_index. enabled {
16141619 return false ;
16151620 }
1621+ if !is_space_default ( & vector_index. config . space ) {
1622+ return false ;
1623+ }
16161624 // Check that embedding_function is default
16171625 if !is_embedding_function_default ( & vector_index. config . embedding_function ) {
16181626 return false ;
@@ -3801,6 +3809,63 @@ mod tests {
38013809 assert ! ( !schema_with_extra_overrides. is_default( ) ) ;
38023810 }
38033811
3812+ #[ test]
3813+ fn test_is_schema_default_with_space ( ) {
3814+ let schema = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3815+ assert ! ( schema. is_default( ) ) ;
3816+
3817+ let mut schema_with_space = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3818+ if let Some ( ref mut float_list) = schema_with_space. defaults . float_list {
3819+ if let Some ( ref mut vector_index) = float_list. vector_index {
3820+ vector_index. config . space = Some ( Space :: Cosine ) ;
3821+ }
3822+ }
3823+ assert ! ( !schema_with_space. is_default( ) ) ;
3824+
3825+ let mut schema_with_space_in_embedding_key = Schema :: new_default ( KnnIndex :: Spann ) ;
3826+ if let Some ( ref mut embedding_key) = schema_with_space_in_embedding_key
3827+ . keys
3828+ . get_mut ( EMBEDDING_KEY )
3829+ {
3830+ if let Some ( ref mut float_list) = embedding_key. float_list {
3831+ if let Some ( ref mut vector_index) = float_list. vector_index {
3832+ vector_index. config . space = Some ( Space :: Cosine ) ;
3833+ }
3834+ }
3835+ }
3836+ assert ! ( !schema_with_space_in_embedding_key. is_default( ) ) ;
3837+ }
3838+
3839+ #[ test]
3840+ fn test_is_schema_default_with_embedding_function ( ) {
3841+ let schema = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3842+ assert ! ( schema. is_default( ) ) ;
3843+
3844+ let mut schema_with_embedding_function = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3845+ if let Some ( ref mut float_list) = schema_with_embedding_function. defaults . float_list {
3846+ if let Some ( ref mut vector_index) = float_list. vector_index {
3847+ vector_index. config . embedding_function =
3848+ Some ( EmbeddingFunctionConfiguration :: Legacy ) ;
3849+ }
3850+ }
3851+ assert ! ( !schema_with_embedding_function. is_default( ) ) ;
3852+
3853+ let mut schema_with_embedding_function_in_embedding_key =
3854+ Schema :: new_default ( KnnIndex :: Spann ) ;
3855+ if let Some ( ref mut embedding_key) = schema_with_embedding_function_in_embedding_key
3856+ . keys
3857+ . get_mut ( EMBEDDING_KEY )
3858+ {
3859+ if let Some ( ref mut float_list) = embedding_key. float_list {
3860+ if let Some ( ref mut vector_index) = float_list. vector_index {
3861+ vector_index. config . embedding_function =
3862+ Some ( EmbeddingFunctionConfiguration :: Legacy ) ;
3863+ }
3864+ }
3865+ }
3866+ assert ! ( !schema_with_embedding_function_in_embedding_key. is_default( ) ) ;
3867+ }
3868+
38043869 #[ test]
38053870 fn test_add_merges_keys_by_value_type ( ) {
38063871 let mut schema_a = Schema :: new_default ( KnnIndex :: Hnsw ) ;
0 commit comments