Generated from protobuf enumDISTANCE_MEASURE_UNSPECIFIED = 0;
EUCLIDEAN
Value: 1
Measures the EUCLIDEAN distance between the vectors. SeeEuclideanto learn
more. The resulting distance decreases the more similar two vectors are.
Generated from protobuf enumEUCLIDEAN = 1;
COSINE
Value: 2
COSINE distance 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. SeeCosine
Similarityto learn
more about COSINE similarity and COSINE distance. The resulting COSINE
distance decreases the more similar two vectors are.
Generated from protobuf enumCOSINE = 2;
DOT_PRODUCT
Value: 3
Similar to cosine but is affected by the magnitude of the vectors. SeeDot Productto learn more.
The resulting distance increases the more similar two vectors are.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Datastore V1 Client - Class DistanceMeasure (1.33.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.33.1 (latest)](/php/docs/reference/cloud-datastore/latest/V1.FindNearest.DistanceMeasure)\n- [1.33.0](/php/docs/reference/cloud-datastore/1.33.0/V1.FindNearest.DistanceMeasure)\n- [1.32.3](/php/docs/reference/cloud-datastore/1.32.3/V1.FindNearest.DistanceMeasure)\n- [1.31.0](/php/docs/reference/cloud-datastore/1.31.0/V1.FindNearest.DistanceMeasure)\n- [1.30.0](/php/docs/reference/cloud-datastore/1.30.0/V1.FindNearest.DistanceMeasure)\n- [1.29.2](/php/docs/reference/cloud-datastore/1.29.2/V1.FindNearest.DistanceMeasure)\n- [1.28.2](/php/docs/reference/cloud-datastore/1.28.2/V1.FindNearest.DistanceMeasure)\n- [1.26.0](/php/docs/reference/cloud-datastore/1.26.0/V1.FindNearest.DistanceMeasure)\n- [1.25.0](/php/docs/reference/cloud-datastore/1.25.0/V1.FindNearest.DistanceMeasure)\n- [1.24.4](/php/docs/reference/cloud-datastore/1.24.4/V1.FindNearest.DistanceMeasure)\n- [1.23.0](/php/docs/reference/cloud-datastore/1.23.0/V1.FindNearest.DistanceMeasure)\n- [1.22.1](/php/docs/reference/cloud-datastore/1.22.1/V1.FindNearest.DistanceMeasure)\n- [1.21.2](/php/docs/reference/cloud-datastore/1.21.2/V1.FindNearest.DistanceMeasure)\n- [1.19.0](/php/docs/reference/cloud-datastore/1.19.0/V1.FindNearest.DistanceMeasure)\n- [1.18.1](/php/docs/reference/cloud-datastore/1.18.1/V1.FindNearest.DistanceMeasure)\n- [1.17.1](/php/docs/reference/cloud-datastore/1.17.1/V1.FindNearest.DistanceMeasure) \nReference documentation and code samples for the Cloud Datastore V1 Client class DistanceMeasure.\n\nThe distance measure to use when comparing vectors.\n\nProtobuf type `google.datastore.v1.FindNearest.DistanceMeasure`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Datastore \\\\ V1 \\\\ FindNearest\n\nMethods\n-------\n\n### static::name\n\n### static::value\n\nConstants\n---------\n\n### DISTANCE_MEASURE_UNSPECIFIED\n\n Value: 0\n\nShould not be set.\n\nGenerated from protobuf enum `DISTANCE_MEASURE_UNSPECIFIED = 0;`\n\n### EUCLIDEAN\n\n Value: 1\n\nMeasures the EUCLIDEAN distance between the vectors. See\n[Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn\nmore. The resulting distance decreases the more similar two vectors are.\n\nGenerated from protobuf enum `EUCLIDEAN = 1;`\n\n### COSINE\n\n Value: 2\n\nCOSINE distance compares vectors based on the angle between them, which\nallows you to measure similarity that isn't based on the vectors\nmagnitude. We recommend using DOT_PRODUCT with unit normalized vectors\ninstead of COSINE distance, which is mathematically equivalent with\nbetter performance. See [Cosine\nSimilarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn\nmore about COSINE similarity and COSINE distance. The resulting COSINE\ndistance decreases the more similar two vectors are.\n\nGenerated from protobuf enum `COSINE = 2;`\n\n### DOT_PRODUCT\n\n Value: 3\n\nSimilar to cosine but is affected by the magnitude of the vectors. See\n[Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.\n\nThe resulting distance increases the more similar two vectors are.\n\nGenerated from protobuf enum `DOT_PRODUCT = 3;`"]]