Class HnswDistanceType

java.lang.Object
io.objectbox.model.HnswDistanceType

public final class HnswDistanceType extends Object
The distance algorithm used by an HNSW index (vector search).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
    Cosine similarity compares two vectors irrespective of their magnitude (compares the angle of two vectors).
    static final short
    For normalized vectors (vector length == 1.0), the dot product is equivalent to the cosine similarity.
    static final short
    A custom dot product similarity measure that does not require the vectors to be normalized.
    static final short
    The default; typically "Euclidean squared" internally.
    static final short
    For geospatial coordinates aka latitude/longitude pairs.
    static final String[]
     
    static final short
    Not a real type, just best practice (e.g.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    name(int e)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • Unknown

      public static final short Unknown
      Not a real type, just best practice (e.g. forward compatibility)
      See Also:
    • Euclidean

      public static final short Euclidean
      The default; typically "Euclidean squared" internally.
      See Also:
    • Cosine

      public static final short 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)
      See Also:
    • DotProduct

      public static final short DotProduct
      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)
      See Also:
    • Geo

      public static final short Geo
      For geospatial coordinates aka latitude/longitude pairs. Note, that the vector dimension must be 2, with the latitude being the first element and longitude the second. Internally, this uses haversine distance.
      See Also:
    • DotProductNonNormalized

      public static final short DotProductNonNormalized
      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)
      See Also:
    • names

      public static final String[] names
  • Constructor Details

    • HnswDistanceType

      private HnswDistanceType()
  • Method Details

    • name

      public static String name(int e)