Package io.agentscope.core.rag.store
Enum Class PgVectorStore.DistanceType
- All Implemented Interfaces:
Serializable,Comparable<PgVectorStore.DistanceType>,Constable
- Enclosing class:
- PgVectorStore
Distance types supported by pgvector.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCosine distance - use<=>operatorInner product - use<#>operator (for normalized vectors, higher is better)L2 (Euclidean) distance - use<->operator -
Method Summary
Modifier and TypeMethodDescriptionGets the index operator class name for this distance type.Gets the SQL operator for this distance type.static PgVectorStore.DistanceTypeReturns the enum constant of this class with the specified name.static PgVectorStore.DistanceType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
L2
L2 (Euclidean) distance - use<->operator -
INNER_PRODUCT
Inner product - use<#>operator (for normalized vectors, higher is better) -
COSINE
Cosine distance - use<=>operator
-
-
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
-
getIndexOps
Gets the index operator class name for this distance type.This is used when creating HNSW indexes in PostgreSQL with pgvector. For example:
CREATE INDEX ... USING hnsw (embedding vector_cosine_ops)- Returns:
- the index operator class name (e.g., "vector_cosine_ops", "vector_l2_ops")
-
getOperator
Gets the SQL operator for this distance type.This operator is used in ORDER BY clauses to sort results by similarity. For example:
ORDER BY embedding <=> query_vector- Returns:
- the SQL operator (e.g., "
<=>" for cosine, "<->" for L2)
-