Module org.elasticsearch.server
Interface DenseVector
- All Known Implementing Classes:
BinaryDenseVector
,ByteBinaryDenseVector
,ByteKnnDenseVector
,KnnDenseVector
public interface DenseVector
DenseVector value type for the painless.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkDimensions
(int dvDims, int qvDims) default double
cosineSimilarity
(byte[] queryVector) Get the cosine similarity with the un-normalized query vectordouble
cosineSimilarity
(byte[] queryVector, float qvMagnitude) Get the cosine similarity with the query vectordefault double
cosineSimilarity
(float[] queryVector) Get the cosine similarity with the un-normalized query vectordouble
cosineSimilarity
(float[] queryVector, boolean normalizeQueryVector) Get the cosine similarity with the query vectordefault double
cosineSimilarity
(Object queryVector) Get the cosine similarity with the un-normalized query vector.double
cosineSimilarity
(List<Number> queryVector) Get the cosine similarity with the un-normalized query vectorint
dotProduct
(byte[] queryVector) double
dotProduct
(float[] queryVector) default double
dotProduct
(Object queryVector) double
dotProduct
(List<Number> queryVector) int
getDims()
float
static float
getMagnitude
(byte[] vector) static float
getMagnitude
(byte[] vector, int dims) static float
getMagnitude
(float[] vector) static float
getMagnitude
(List<Number> vector) float[]
boolean
isEmpty()
int
l1Norm
(byte[] queryVector) double
l1Norm
(float[] queryVector) default double
double
double
l2Norm
(byte[] queryVector) double
l2Norm
(float[] queryVector) default double
double
int
size()
-
Field Details
-
EMPTY
-
-
Method Details
-
getVector
float[] getVector() -
getMagnitude
float getMagnitude() -
dotProduct
int dotProduct(byte[] queryVector) -
dotProduct
double dotProduct(float[] queryVector) -
dotProduct
-
dotProduct
-
l1Norm
int l1Norm(byte[] queryVector) -
l1Norm
double l1Norm(float[] queryVector) -
l1Norm
-
l1Norm
-
l2Norm
double l2Norm(byte[] queryVector) -
l2Norm
double l2Norm(float[] queryVector) -
l2Norm
-
l2Norm
-
cosineSimilarity
default double cosineSimilarity(byte[] queryVector) Get the cosine similarity with the un-normalized query vector -
cosineSimilarity
double cosineSimilarity(byte[] queryVector, float qvMagnitude) Get the cosine similarity with the query vector- Parameters:
qvMagnitude
- - pre-calculated magnitude of the query vector
-
cosineSimilarity
default double cosineSimilarity(float[] queryVector) Get the cosine similarity with the un-normalized query vector -
cosineSimilarity
double cosineSimilarity(float[] queryVector, boolean normalizeQueryVector) Get the cosine similarity with the query vector- Parameters:
normalizeQueryVector
- - normalize the query vector, does not change the contents of passed in query vector
-
cosineSimilarity
Get the cosine similarity with the un-normalized query vector -
cosineSimilarity
Get the cosine similarity with the un-normalized query vector. Handles queryVectors of type float[] and List. -
isEmpty
boolean isEmpty() -
getDims
int getDims() -
size
int size() -
getMagnitude
static float getMagnitude(byte[] vector) -
getMagnitude
static float getMagnitude(byte[] vector, int dims) -
getMagnitude
static float getMagnitude(float[] vector) -
getMagnitude
-
checkDimensions
static void checkDimensions(int dvDims, int qvDims)
-