VectorIndexConfiguration

public struct VectorIndexConfiguration : IndexConfiguration, IndexConfigConvertable

ENTERPRISE EDITION ONLY

Configuration for creating vector indexes.

  • The SQL++ expression returning either a vector, which is an array of 32-bit floating-point numbers, or a Base64 string representing an array of 32-bit floating-point numbers in little-endian order.

    When lazy index is enabled, an expression will return a value for computing a vector lazily by using IndexUpdater instead.

    Declaration

    Swift

    public let expression: String
  • The number of vector dimensions

    Note

    The maximum number of vector dimensions supported is 4096.

    Declaration

    Swift

    public let dimensions: UInt32
  • The number of centroids which is the number buckets to partition the vectors in the index.

    Note

    The recommended number of centroids is the square root of the number of vectors to be indexed, and the maximum number of centroids supported is 64,000.

    Declaration

    Swift

    public let centroids: UInt32
  • Vector encoding type. The default value is 8-bits Scalar Quantizer.

    Declaration

    Swift

    public var encoding: VectorEncoding
  • Distance Metric type. The default value is euclidean distance.

    Declaration

    Swift

    public var metric: DistanceMetric
  • The minimum number of vectors for training the index. The default value is zero, meaning that minTrainingSize will be automatically calculated by the index based on the number of centroids specified, encoding types, and the encoding parameters.

    The training will occur at or before the APPROX_VECTOR_DISANCE query is executed, provided there is enough data at that time, and consequently, if training is triggered during a query, the query may take longer to return results.

    If a query is executed against the index before it is trained, a full scan of the vectors will be performed. If there are insufficient vectors in the database for training, a warning message will be logged, indicating the required number of vectors.

    Declaration

    Swift

    public var minTrainingSize: UInt32
  • The maximum number of vectors used for training the index. The default value is zero, meaning that the maxTrainingSize will be automatically calulated by the index based on the number of centroids specified, encoding types, and the encoding parameters.

    Declaration

    Swift

    public var maxTrainingSize: UInt32
  • The number of centroids that will be scanned during a query. The default value is zero, meaning that the numProbes will be automatically calulated by the index based on the number of centroids specified.

    Declaration

    Swift

    public var numProbes: UInt32
  • The boolean flag indicating that index is lazy or not. The default value is false. If the index is lazy, it will not be automatically updated when the documents in the collection are changed, except when the documents are deleted or purged.

    When configuring the index to be lazy, the expression set to the config is the expression that returns a value used for computing the vector.

    To update the lazy index, use a LIndexUpdater object obtained from a QueryIndex object, which can be retrieved from a Collection object.

    Declaration

    Swift

    public var isLazy: Bool
  • Initializes the VectorIndexConfiguration.

    Declaration

    Swift

    public init(expression: String, dimensions: UInt32, centroids: UInt32)

    Parameters

    expression

    The SQL++ expression returning a vector which is an array of numbers.

    dimensions

    The number of dimensions of the vectors to be indexed. The vectors that do not have the same dimensions specified in the config will not be indexed. The dimensions must be >= 2 and <= 4096.

    centroids

    The number of centroids which is the number buckets to partition the vectors in the index. The number of centroids will be based on the expected number of vectors to be indexed; one suggested rule is to use the square root of the number of vectors. The centroids must be >= 1 and <= 64000.

  • [false] Vectors are not lazily indexed, by default

    Declaration

    Swift

    static let defaultIsLazy: Bool
  • [ScalarQuantizerType.SQ8] Vectors are encoded by using 8-bit Scalar Quantizer encoding, by default

    Declaration

    Swift

    static let defaultEncoding: ScalarQuantizerType
  • [DistanceMetric.euclideanSquared] By default, vectors are compared using Squared Euclidean metrics

    Declaration

    Swift

    static let defaultDistanceMetric: DistanceMetric
  • [0] By default, the value will be determined based on the number of centroids, encoding types, and the encoding parameters.

    Declaration

    Swift

    static let defaultMinTrainingSize: UInt32
  • [0] By default, the value will be determined based on the number of centroids, encoding types, and the encoding parameters

    Declaration

    Swift

    static let defaultMaxTrainingSize: UInt32
  • [0] By default, the value will be determined based on the number of centroids.

    Declaration

    Swift

    static let defaultNumProbes: UInt32