Class FindNearest (2.16.0)

FindNearest(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Nearest Neighbors search config.

Attributes

NameDescription
vector_field google.cloud.firestore_v1.types.StructuredQuery.FieldReference
Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.
query_vector google.cloud.firestore_v1.types.Value
Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.
distance_measure google.cloud.firestore_v1.types.StructuredQuery.FindNearest.DistanceMeasure
Required. The Distance Measure to use, required.
limit google.protobuf.wrappers_pb2.Int32Value
Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.

Classes

DistanceMeasure

DistanceMeasure(value)

The distance measure to use when comparing vectors.

Values: DISTANCE_MEASURE_UNSPECIFIED (0): Should not be set. EUCLIDEAN (1): Measures the EUCLIDEAN distance between the vectors. See Euclidean <https://en.wikipedia.org/wiki/Euclidean_distance> to learn more COSINE (2): Compares vectors based on the angle between them, which allows you to measure similarity that isn't based on the vectors magnitude. We recommend using DOT_PRODUCT with unit normalized vectors instead of COSINE distance, which is mathematically equivalent with better performance. See Cosine Similarity <https://en.wikipedia.org/wiki/Cosine_similarity> to learn more. DOT_PRODUCT (3): Similar to cosine but is affected by the magnitude of the vectors. See Dot Product <https://en.wikipedia.org/wiki/Dot_product>__ to learn more.