@@ -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 ;
@@ -3804,6 +3812,63 @@ mod tests {
38043812 assert ! ( !schema_with_extra_overrides. is_default( ) ) ;
38053813 }
38063814
3815+ #[ test]
3816+ fn test_is_schema_default_with_space ( ) {
3817+ let schema = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3818+ assert ! ( schema. is_default( ) ) ;
3819+
3820+ let mut schema_with_space = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3821+ if let Some ( ref mut float_list) = schema_with_space. defaults . float_list {
3822+ if let Some ( ref mut vector_index) = float_list. vector_index {
3823+ vector_index. config . space = Some ( Space :: Cosine ) ;
3824+ }
3825+ }
3826+ assert ! ( !schema_with_space. is_default( ) ) ;
3827+
3828+ let mut schema_with_space_in_embedding_key = Schema :: new_default ( KnnIndex :: Spann ) ;
3829+ if let Some ( ref mut embedding_key) = schema_with_space_in_embedding_key
3830+ . keys
3831+ . get_mut ( EMBEDDING_KEY )
3832+ {
3833+ if let Some ( ref mut float_list) = embedding_key. float_list {
3834+ if let Some ( ref mut vector_index) = float_list. vector_index {
3835+ vector_index. config . space = Some ( Space :: Cosine ) ;
3836+ }
3837+ }
3838+ }
3839+ assert ! ( !schema_with_space_in_embedding_key. is_default( ) ) ;
3840+ }
3841+
3842+ #[ test]
3843+ fn test_is_schema_default_with_embedding_function ( ) {
3844+ let schema = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3845+ assert ! ( schema. is_default( ) ) ;
3846+
3847+ let mut schema_with_embedding_function = Schema :: new_default ( KnnIndex :: Hnsw ) ;
3848+ if let Some ( ref mut float_list) = schema_with_embedding_function. defaults . float_list {
3849+ if let Some ( ref mut vector_index) = float_list. vector_index {
3850+ vector_index. config . embedding_function =
3851+ Some ( EmbeddingFunctionConfiguration :: Legacy ) ;
3852+ }
3853+ }
3854+ assert ! ( !schema_with_embedding_function. is_default( ) ) ;
3855+
3856+ let mut schema_with_embedding_function_in_embedding_key =
3857+ Schema :: new_default ( KnnIndex :: Spann ) ;
3858+ if let Some ( ref mut embedding_key) = schema_with_embedding_function_in_embedding_key
3859+ . keys
3860+ . get_mut ( EMBEDDING_KEY )
3861+ {
3862+ if let Some ( ref mut float_list) = embedding_key. float_list {
3863+ if let Some ( ref mut vector_index) = float_list. vector_index {
3864+ vector_index. config . embedding_function =
3865+ Some ( EmbeddingFunctionConfiguration :: Legacy ) ;
3866+ }
3867+ }
3868+ }
3869+ assert ! ( !schema_with_embedding_function_in_embedding_key. is_default( ) ) ;
3870+ }
3871+
38073872 #[ test]
38083873 fn test_add_merges_keys_by_value_type ( ) {
38093874 let mut schema_a = Schema :: new_default ( KnnIndex :: Hnsw ) ;
0 commit comments