public sealed class FindNearest : IMessage<FindNearest>, IEquatable<FindNearest>, IDeepCloneable<FindNearest>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Datastore v1 API class FindNearest.
Nearest Neighbors search config. The ordering provided by FindNearest
supersedes the order_by stage. If multiple documents have the same vector
distance, the returned document order is not guaranteed to be stable between
queries.
public string DistanceResultProperty { get; set; }
Optional. Optional name of the field to output the result of the vector
distance calculation. Must conform to [entity
property][google.datastore.v1.Entity.properties] limitations.
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-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eFindNearest\u003c/code\u003e class in the Google Cloud Datastore v1 API facilitates searching for nearest neighbors in a dataset, with version 4.15.0 being the latest available version.\u003c/p\u003e\n"],["\u003cp\u003eThis class is part of the \u003ccode\u003eGoogle.Cloud.Datastore.V1\u003c/code\u003e namespace and is implemented in the \u003ccode\u003eGoogle.Cloud.Datastore.V1.dll\u003c/code\u003e assembly, offering functionality for finding documents closest to a specified vector.\u003c/p\u003e\n"],["\u003cp\u003eIt supports configuration of distance measurements, with required parameters like \u003ccode\u003eDistanceMeasure\u003c/code\u003e, \u003ccode\u003eLimit\u003c/code\u003e, \u003ccode\u003eQueryVector\u003c/code\u003e, and \u003ccode\u003eVectorProperty\u003c/code\u003e, and optional parameters such as \u003ccode\u003eDistanceResultProperty\u003c/code\u003e, and \u003ccode\u003eDistanceThreshold\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFindNearest\u003c/code\u003e implements multiple interfaces including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e which allow the class to be used in a wide variety of use cases.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFindNearest\u003c/code\u003e class allows the setting of a query vector to search for, with a limit of 2048 dimensions, and the specification of a vector property to search upon.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Datastore v1 API - Class FindNearest (4.15.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.15.0 (latest)](/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.FindNearest)\n- [4.14.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.14.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.13.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.13.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.12.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.12.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.11.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.11.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.10.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.10.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.9.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.9.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.8.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.8.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.7.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.7.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.6.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.5.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.4.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.3.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.2.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.1.0/Google.Cloud.Datastore.V1.FindNearest)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/4.0.0/Google.Cloud.Datastore.V1.FindNearest)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/3.5.0/Google.Cloud.Datastore.V1.FindNearest)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/3.4.0/Google.Cloud.Datastore.V1.FindNearest)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/3.3.0/Google.Cloud.Datastore.V1.FindNearest)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Datastore.V1/3.2.0/Google.Cloud.Datastore.V1.FindNearest) \n\n public sealed class FindNearest : IMessage\u003cFindNearest\u003e, IEquatable\u003cFindNearest\u003e, IDeepCloneable\u003cFindNearest\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Datastore v1 API class FindNearest.\n\nNearest Neighbors search config. The ordering provided by FindNearest\nsupersedes the order_by stage. If multiple documents have the same vector\ndistance, the returned document order is not guaranteed to be stable between\nqueries. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e FindNearest \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[FindNearest](/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.FindNearest), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[FindNearest](/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.FindNearest), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[FindNearest](/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.FindNearest), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Datastore.V1](/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Datastore.V1.dll\n\nConstructors\n------------\n\n### FindNearest()\n\n public FindNearest()\n\n### FindNearest(FindNearest)\n\n public FindNearest(FindNearest other)\n\nProperties\n----------\n\n### DistanceMeasure\n\n public FindNearest.Types.DistanceMeasure DistanceMeasure { get; set; }\n\nRequired. The Distance Measure to use, required.\n\n### DistanceResultProperty\n\n public string DistanceResultProperty { get; set; }\n\nOptional. Optional name of the field to output the result of the vector\ndistance calculation. Must conform to \\[entity\nproperty\\]\\[google.datastore.v1.Entity.properties\\] limitations.\n\n### DistanceThreshold\n\n public double? DistanceThreshold { get; set; }\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### Limit\n\n public int? Limit { get; set; }\n\nRequired. The number of nearest neighbors to return. Must be a positive\ninteger of no more than 100.\n\n### QueryVector\n\n public Value QueryVector { get; set; }\n\nRequired. The query vector that we are searching on. Must be a vector of no\nmore than 2048 dimensions.\n\n### VectorProperty\n\n public PropertyReference VectorProperty { get; set; }\n\nRequired. An indexed vector property to search upon. Only documents which\ncontain vectors whose dimensionality match the query_vector can be\nreturned."]]