Cloud Datastore V1 Client - Class DistanceMeasure (2.0.3) Stay organized with collections Save and categorize content based on your preferences.
Reference documentation and code samples for the Cloud Datastore V1 Client class DistanceMeasure.
The distance measure to use when comparing vectors.
Protobuf typegoogle.datastore.v1.FindNearest.DistanceMeasure
Namespace
Google \ Cloud \ Datastore \ V1 \ FindNearestMethods
static::name
| Parameter | |
|---|---|
| Name | Description |
value | mixed |
static::value
| Parameter | |
|---|---|
| Name | Description |
name | mixed |
Constants
DISTANCE_MEASURE_UNSPECIFIED
Value: 0Should not be set.
Generated from protobuf enumDISTANCE_MEASURE_UNSPECIFIED = 0;
EUCLIDEAN
Value: 1Measures the EUCLIDEAN distance between the vectors. SeeEuclidean to learnmore. The resulting distance decreases the more similar two vectors are.
Generated from protobuf enumEUCLIDEAN = 1;
COSINE
Value: 2COSINE distance compares vectors based on the angle between them, whichallows you to measure similarity that isn't based on the vectorsmagnitude. We recommend using DOT_PRODUCT with unit normalized vectorsinstead of COSINE distance, which is mathematically equivalent withbetter performance. SeeCosineSimilarity to learnmore about COSINE similarity and COSINE distance. The resulting COSINEdistance decreases the more similar two vectors are.
Generated from protobuf enumCOSINE = 2;
DOT_PRODUCT
Value: 3Similar to cosine but is affected by the magnitude of the vectors. SeeDot Product to learn more.
The resulting distance increases the more similar two vectors are.
Generated from protobuf enumDOT_PRODUCT = 3;
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-01-24 UTC.