Enum Class VectorDistanceType
- All Implemented Interfaces:
Serializable
,Comparable<VectorDistanceType>
,Constable
HnswIndex
(vector search).-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCosine similarity compares two vectors irrespective of their magnitude (compares the angle of two vectors).The default; currentlyEUCLIDEAN
.For normalized vectors (vector length == 1.0), the dot product is equivalent to the cosine similarity.A custom dot product similarity measure that does not require the vectors to be normalized.Typically "Euclidean squared" internally.For geospatial coordinates, more specifically latitude and longitude pairs. -
Method Summary
Modifier and TypeMethodDescriptionstatic VectorDistanceType
Returns the enum constant of this class with the specified name.static VectorDistanceType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DEFAULT
The default; currentlyEUCLIDEAN
. -
EUCLIDEAN
Typically "Euclidean squared" internally. -
COSINE
Cosine similarity compares two vectors irrespective of their magnitude (compares the angle of two vectors).Often used for document or semantic similarity.
Value range: 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
-
DOT_PRODUCT
For normalized vectors (vector length == 1.0), the dot product is equivalent to the cosine similarity.Because of this, the dot product is often preferred as it performs better.
Value range (normalized vectors): 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
-
GEO
For geospatial coordinates, more specifically latitude and longitude pairs.Note, the vector dimension should be 2, with the latitude being the first element and longitude the second. If the vector has more than 2 dimensions, only the first 2 dimensions are used. If the vector has fewer than 2 dimensions, the distance is always zero.
Internally, this uses haversine distance.
Value range: 0 km - 6371 * π km (approx. 20015.09 km; half the Earth's circumference)
-
DOT_PRODUCT_NON_NORMALIZED
A custom dot product similarity measure that does not require the vectors to be normalized.Note: this is no replacement for cosine similarity (like DotProduct for normalized vectors is). The non-linear conversion provides a high precision over the entire float range (for the raw dot product). The higher the dot product, the lower the distance is (the nearer the vectors are). The more negative the dot product, the higher the distance is (the farther the vectors are).
Value range: 0.0 - 2.0 (nonlinear; 0.0: nearest, 1.0: orthogonal, 2.0: farthest)
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-