Optional. Option to specify a threshold for which no less similar documents
will be returned. The behavior of the specified distance_measure will
affect the meaning of the distance threshold. Since DOT_PRODUCT distances
increase when the vectors are more similar, the comparison is inverted.
For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
For DOT_PRODUCT: WHERE distance >= distance_threshold
Optional. Option to specify a threshold for which no less similar documents
will be returned. The behavior of the specified distance_measure will
affect the meaning of the distance threshold. Since DOT_PRODUCT distances
increase when the vectors are more similar, the comparison is inverted.
For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
For DOT_PRODUCT: WHERE distance >= distance_threshold
Optional. Option to specify a threshold for which no less similar documents
will be returned. The behavior of the specified distance_measure will
affect the meaning of the distance threshold. Since DOT_PRODUCT distances
increase when the vectors are more similar, the comparison is inverted.
For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
For DOT_PRODUCT: WHERE distance >= distance_threshold
[[["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,["# Interface FindNearestOrBuilder (2.31.2)\n\nVersion latestkeyboard_arrow_down\n\n- [2.31.2 (latest)](/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.31.1](/java/docs/reference/google-cloud-datastore/2.31.1/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.30.0](/java/docs/reference/google-cloud-datastore/2.30.0/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.29.1](/java/docs/reference/google-cloud-datastore/2.29.1/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.28.2](/java/docs/reference/google-cloud-datastore/2.28.2/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.27.1](/java/docs/reference/google-cloud-datastore/2.27.1/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.26.4](/java/docs/reference/google-cloud-datastore/2.26.4/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.25.2](/java/docs/reference/google-cloud-datastore/2.25.2/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.24.3](/java/docs/reference/google-cloud-datastore/2.24.3/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.23.0](/java/docs/reference/google-cloud-datastore/2.23.0/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.22.0](/java/docs/reference/google-cloud-datastore/2.22.0/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.21.3](/java/docs/reference/google-cloud-datastore/2.21.3/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.20.2](/java/docs/reference/google-cloud-datastore/2.20.2/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.19.2](/java/docs/reference/google-cloud-datastore/2.19.2/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.18.5](/java/docs/reference/google-cloud-datastore/2.18.5/com.google.datastore.v1.FindNearestOrBuilder)\n- [2.17.6](/java/docs/reference/google-cloud-datastore/2.17.6/com.google.datastore.v1.FindNearestOrBuilder) \n\n public interface FindNearestOrBuilder extends MessageOrBuilder\n\nImplements\n----------\n\n[MessageOrBuilder](https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder.html)\n\nMethods\n-------\n\n### getDistanceMeasure()\n\n public abstract FindNearest.DistanceMeasure getDistanceMeasure()\n\nRequired. The Distance Measure to use, required.\n\n`\n.google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### getDistanceMeasureValue()\n\n public abstract int getDistanceMeasureValue()\n\nRequired. The Distance Measure to use, required.\n\n`\n.google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### getDistanceResultProperty()\n\n public abstract String getDistanceResultProperty()\n\nOptional. Optional name of the field to output the result of the vector\ndistance calculation. Must conform to entity property limitations.\n\n`string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL];`\n\n### getDistanceResultPropertyBytes()\n\n public abstract ByteString getDistanceResultPropertyBytes()\n\nOptional. Optional name of the field to output the result of the vector\ndistance calculation. Must conform to entity property limitations.\n\n`string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL];`\n\n### getDistanceThreshold()\n\n public abstract DoubleValue getDistanceThreshold()\n\nOptional. Option to specify a threshold for which no less similar documents\nwill be returned. The behavior of the specified `distance_measure` will\naffect the meaning of the distance threshold. Since DOT_PRODUCT distances\nincrease when the vectors are more similar, the comparison is inverted.\n\nFor EUCLIDEAN, COSINE: WHERE distance \\\u003c= distance_threshold\nFor DOT_PRODUCT: WHERE distance \\\u003e= distance_threshold\n\n`\n.google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL];\n`\n\n### getDistanceThresholdOrBuilder()\n\n public abstract DoubleValueOrBuilder getDistanceThresholdOrBuilder()\n\nOptional. Option to specify a threshold for which no less similar documents\nwill be returned. The behavior of the specified `distance_measure` will\naffect the meaning of the distance threshold. Since DOT_PRODUCT distances\nincrease when the vectors are more similar, the comparison is inverted.\n\nFor EUCLIDEAN, COSINE: WHERE distance \\\u003c= distance_threshold\nFor DOT_PRODUCT: WHERE distance \\\u003e= distance_threshold\n\n`\n.google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL];\n`\n\n### getLimit()\n\n public abstract Int32Value getLimit()\n\nRequired. The number of nearest neighbors to return. Must be a positive\ninteger of no more than 100.\n\n`.google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED];`\n\n### getLimitOrBuilder()\n\n public abstract Int32ValueOrBuilder getLimitOrBuilder()\n\nRequired. The number of nearest neighbors to return. Must be a positive\ninteger of no more than 100.\n\n`.google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED];`\n\n### getQueryVector()\n\n public abstract Value getQueryVector()\n\nRequired. The query vector that we are searching on. Must be a vector of no\nmore than 2048 dimensions.\n\n`.google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### getQueryVectorOrBuilder()\n\n public abstract ValueOrBuilder getQueryVectorOrBuilder()\n\nRequired. The query vector that we are searching on. Must be a vector of no\nmore than 2048 dimensions.\n\n`.google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### getVectorProperty()\n\n public abstract PropertyReference getVectorProperty()\n\nRequired. An indexed vector property to search upon. Only documents which\ncontain vectors whose dimensionality match the query_vector can be\nreturned.\n\n`\n.google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### getVectorPropertyOrBuilder()\n\n public abstract PropertyReferenceOrBuilder getVectorPropertyOrBuilder()\n\nRequired. An indexed vector property to search upon. Only documents which\ncontain vectors whose dimensionality match the query_vector can be\nreturned.\n\n`\n.google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### hasDistanceThreshold()\n\n public abstract boolean hasDistanceThreshold()\n\nOptional. Option to specify a threshold for which no less similar documents\nwill be returned. The behavior of the specified `distance_measure` will\naffect the meaning of the distance threshold. Since DOT_PRODUCT distances\nincrease when the vectors are more similar, the comparison is inverted.\n\nFor EUCLIDEAN, COSINE: WHERE distance \\\u003c= distance_threshold\nFor DOT_PRODUCT: WHERE distance \\\u003e= distance_threshold\n\n`\n.google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL];\n`\n\n### hasLimit()\n\n public abstract boolean hasLimit()\n\nRequired. The number of nearest neighbors to return. Must be a positive\ninteger of no more than 100.\n\n`.google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED];`\n\n### hasQueryVector()\n\n public abstract boolean hasQueryVector()\n\nRequired. The query vector that we are searching on. Must be a vector of no\nmore than 2048 dimensions.\n\n`.google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED];\n`\n\n### hasVectorProperty()\n\n public abstract boolean hasVectorProperty()\n\nRequired. An indexed vector property to search upon. Only documents which\ncontain vectors whose dimensionality match the query_vector can be\nreturned.\n\n`\n.google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED];\n`"]]