Table of Contents

Method SimilarityDotProduct

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

SimilarityDotProduct<TElement>(IEnumerable<TElement>, IEnumerable<TElement>, bool)

Translated to the "$similarityDotProduct" operator in MQL to measure the similarity between two vectors.

public static double SimilarityDotProduct<TElement>(IEnumerable<TElement> vector1, IEnumerable<TElement> vector2, bool normalizeScore)

Parameters

vector1 IEnumerable<TElement>

The first vector to compare. Must have the same length as the second vector.

vector2 IEnumerable<TElement>

The second vector to compare. Must have the same length as the first vector.

normalizeScore bool

Whether to normalize the result for use as a vector search score.

Returns

double

The dot-product measure between the two vectors.

Type Parameters

TElement

The vector element type

Exceptions

NotSupportedException

if used for anything other than translating to MQL.

SimilarityDotProduct<TElement>(ReadOnlyMemory<TElement>, ReadOnlyMemory<TElement>, bool)

Translated to the "$similarityDotProduct" operator in MQL to measure the similarity between two vectors.

public static double SimilarityDotProduct<TElement>(ReadOnlyMemory<TElement> vector1, ReadOnlyMemory<TElement> vector2, bool normalizeScore)

Parameters

vector1 ReadOnlyMemory<TElement>

The first vector to compare. Must have the same length as the second vector.

vector2 ReadOnlyMemory<TElement>

The second vector to compare. Must have the same length as the first vector.

normalizeScore bool

Whether to normalize the result for use as a vector search score.

Returns

double

The dot-product measure between the two vectors.

Type Parameters

TElement

The vector element type

Exceptions

NotSupportedException

if used for anything other than translating to MQL.