Class StructuredQuery.FindNearest (3.28.0)

public static final class StructuredQuery.FindNearest extends GeneratedMessageV3 implements StructuredQuery.FindNearestOrBuilder

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.

Protobuf type google.firestore.v1.StructuredQuery.FindNearest

Static Fields

DISTANCE_MEASURE_FIELD_NUMBER

public static final int DISTANCE_MEASURE_FIELD_NUMBER
Field Value
Type Description
int

DISTANCE_RESULT_FIELD_FIELD_NUMBER

public static final int DISTANCE_RESULT_FIELD_FIELD_NUMBER
Field Value
Type Description
int

DISTANCE_THRESHOLD_FIELD_NUMBER

public static final int DISTANCE_THRESHOLD_FIELD_NUMBER
Field Value
Type Description
int

LIMIT_FIELD_NUMBER

public static final int LIMIT_FIELD_NUMBER
Field Value
Type Description
int

QUERY_VECTOR_FIELD_NUMBER

public static final int QUERY_VECTOR_FIELD_NUMBER
Field Value
Type Description
int

VECTOR_FIELD_FIELD_NUMBER

public static final int VECTOR_FIELD_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static StructuredQuery.FindNearest getDefaultInstance()
Returns
Type Description
StructuredQuery.FindNearest

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

newBuilder()

public static StructuredQuery.FindNearest.Builder newBuilder()
Returns
Type Description
StructuredQuery.FindNearest.Builder

newBuilder(StructuredQuery.FindNearest prototype)

public static StructuredQuery.FindNearest.Builder newBuilder(StructuredQuery.FindNearest prototype)
Parameter
Name Description
prototype StructuredQuery.FindNearest
Returns
Type Description
StructuredQuery.FindNearest.Builder

parseDelimitedFrom(InputStream input)

public static StructuredQuery.FindNearest parseDelimitedFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static StructuredQuery.FindNearest parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
IOException

parseFrom(byte[] data)

public static StructuredQuery.FindNearest parseFrom(byte[] data)
Parameter
Name Description
data byte[]
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static StructuredQuery.FindNearest parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data)

public static StructuredQuery.FindNearest parseFrom(ByteString data)
Parameter
Name Description
data ByteString
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static StructuredQuery.FindNearest parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static StructuredQuery.FindNearest parseFrom(CodedInputStream input)
Parameter
Name Description
input CodedInputStream
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static StructuredQuery.FindNearest parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
IOException

parseFrom(InputStream input)

public static StructuredQuery.FindNearest parseFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static StructuredQuery.FindNearest parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
IOException

parseFrom(ByteBuffer data)

public static StructuredQuery.FindNearest parseFrom(ByteBuffer data)
Parameter
Name Description
data ByteBuffer
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static StructuredQuery.FindNearest parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteBuffer
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest
Exceptions
Type Description
InvalidProtocolBufferException

parser()

public static Parser<StructuredQuery.FindNearest> parser()
Returns
Type Description
Parser<FindNearest>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
Name Description
obj Object
Returns
Type Description
boolean
Overrides

getDefaultInstanceForType()

public StructuredQuery.FindNearest getDefaultInstanceForType()
Returns
Type Description
StructuredQuery.FindNearest

getDistanceMeasure()

public StructuredQuery.FindNearest.DistanceMeasure getDistanceMeasure()

Required. The distance measure to use, required.

.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
StructuredQuery.FindNearest.DistanceMeasure

The distanceMeasure.

getDistanceMeasureValue()

public int getDistanceMeasureValue()

Required. The distance measure to use, required.

.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
int

The enum numeric value on the wire for distanceMeasure.

getDistanceResultField()

public String getDistanceResultField()

Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to document field name limitations.

string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
String

The distanceResultField.

getDistanceResultFieldBytes()

public ByteString getDistanceResultFieldBytes()

Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to document field name limitations.

string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
ByteString

The bytes for distanceResultField.

getDistanceThreshold()

public DoubleValue getDistanceThreshold()

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

.google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
DoubleValue

The distanceThreshold.

getDistanceThresholdOrBuilder()

public DoubleValueOrBuilder getDistanceThresholdOrBuilder()

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

.google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
DoubleValueOrBuilder

getLimit()

public Int32Value getLimit()

Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.

.google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Int32Value

The limit.

getLimitOrBuilder()

public Int32ValueOrBuilder getLimitOrBuilder()

Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.

.google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Int32ValueOrBuilder

getParserForType()

public Parser<StructuredQuery.FindNearest> getParserForType()
Returns
Type Description
Parser<FindNearest>
Overrides

getQueryVector()

public Value getQueryVector()

Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.

.google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Value

The queryVector.

getQueryVectorOrBuilder()

public ValueOrBuilder getQueryVectorOrBuilder()

Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.

.google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
ValueOrBuilder

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
int
Overrides

getVectorField()

public StructuredQuery.FieldReference getVectorField()

Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.

.google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
StructuredQuery.FieldReference

The vectorField.

getVectorFieldOrBuilder()

public StructuredQuery.FieldReferenceOrBuilder getVectorFieldOrBuilder()

Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.

.google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
StructuredQuery.FieldReferenceOrBuilder

hasDistanceThreshold()

public boolean hasDistanceThreshold()

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

.google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the distanceThreshold field is set.

hasLimit()

public boolean hasLimit()

Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.

.google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the limit field is set.

hasQueryVector()

public boolean hasQueryVector()

Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.

.google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the queryVector field is set.

hasVectorField()

public boolean hasVectorField()

Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.

.google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the vectorField field is set.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

newBuilderForType()

public StructuredQuery.FindNearest.Builder newBuilderForType()
Returns
Type Description
StructuredQuery.FindNearest.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected StructuredQuery.FindNearest.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
Name Description
parent BuilderParent
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
Name Description
unused UnusedPrivateParameter
Returns
Type Description
Object
Overrides

toBuilder()

public StructuredQuery.FindNearest.Builder toBuilder()
Returns
Type Description
StructuredQuery.FindNearest.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException