@@ -519,10 +519,9 @@ func processNewIndexRequest(
519519}
520520
521521// validateVectorIndexDescription checks and fills in the vector-specific parts of an index request.
522- // The field must hold a float32 array, and dimensions must be set unless the field is an @embedding,
523- // whose model fixes the vector length. It also defaults the algorithm, metric, and any missing
524- // params (mutating desc.Vector), so a request made through the index API works the same as one from
525- // the @index directive's vector configuration.
522+ // The field must hold a float32 array, and dimensions must be greater than zero. It also defaults
523+ // the algorithm, metric, and any missing params (mutating desc.Vector), so a request made through
524+ // the index API works the same as one from the @index directive's vector configuration.
526525//
527526// The field is guaranteed to exist here because validateIndexDescription and
528527// checkExistingFieldsAndAdjustRelFieldNames run before this and already check that.
@@ -543,10 +542,13 @@ func validateVectorIndexDescription(def client.CollectionVersion, desc client.Ne
543542 if ! client .IsVectorEmbeddingCompatible (field .Kind ) {
544543 return NewErrUnsupportedVectorIndexFieldType (field .Kind )
545544 }
545+ if desc .Vector .Dimensions == 0 {
546+ return NewErrVectorIndexMissingDimensions (fieldName )
547+ }
546548
547- // The config object present is what picks the algorithm, so the caller never sets one directly.
548- // Fill in the algorithm, metric, and any missing params with defaults. A nil config means an empty
549- // one, so a caller can leave it out and still get a working HNSW index.
549+ // The algorithm config object present is what picks the algorithm, so the caller never sets one
550+ // directly. Fill in the algorithm, metric, and any missing params with defaults. A nil HNSW config
551+ // means an empty one, so a caller can leave it out and still get a working HNSW index.
550552 if desc .Vector .HNSW == nil {
551553 desc .Vector .HNSW = & client.HNSWParams {}
552554 }
@@ -572,19 +574,7 @@ func validateVectorIndexDescription(def client.CollectionVersion, desc client.Ne
572574 return err
573575 }
574576
575- if desc .Vector .Dimensions > 0 {
576- return nil
577- }
578-
579- // No dimensions were given. That is only allowed when the field is an @embedding, since the
580- // model then fixes the dimensions. The value itself is filled in later.
581- for _ , embedding := range def .VectorEmbeddings {
582- if embedding .FieldName == fieldName {
583- return nil
584- }
585- }
586-
587- return NewErrVectorIndexMissingDimensions (fieldName )
577+ return nil
588578}
589579
590580// validateNoConflictingVectorIndexMetric rejects creating a vector index on a field that another
0 commit comments