Class StructuredQuery.FindNearest.Builder (3.30.2)

public static final class StructuredQuery.FindNearest.Builder extends GeneratedMessageV3.Builder<StructuredQuery.FindNearest.Builder> 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 Methods

getDescriptor()

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

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public StructuredQuery.FindNearest.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

build()

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

buildPartial()

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

clear()

public StructuredQuery.FindNearest.Builder clear()
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

clearDistanceMeasure()

public StructuredQuery.FindNearest.Builder clearDistanceMeasure()

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.Builder

This builder for chaining.

clearDistanceResultField()

public StructuredQuery.FindNearest.Builder clearDistanceResultField()

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
StructuredQuery.FindNearest.Builder

This builder for chaining.

clearDistanceThreshold()

public StructuredQuery.FindNearest.Builder clearDistanceThreshold()

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
StructuredQuery.FindNearest.Builder

clearField(Descriptors.FieldDescriptor field)

public StructuredQuery.FindNearest.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

clearLimit()

public StructuredQuery.FindNearest.Builder clearLimit()

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
StructuredQuery.FindNearest.Builder

clearOneof(Descriptors.OneofDescriptor oneof)

public StructuredQuery.FindNearest.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

clearQueryVector()

public StructuredQuery.FindNearest.Builder clearQueryVector()

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
StructuredQuery.FindNearest.Builder

clearVectorField()

public StructuredQuery.FindNearest.Builder clearVectorField()

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.FindNearest.Builder

clone()

public StructuredQuery.FindNearest.Builder clone()
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

getDefaultInstanceForType()

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

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

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.

getDistanceThresholdBuilder()

public DoubleValue.Builder getDistanceThresholdBuilder()

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
Builder

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.

getLimitBuilder()

public Int32Value.Builder getLimitBuilder()

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
Builder

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

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.

getQueryVectorBuilder()

public Value.Builder getQueryVectorBuilder()

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.Builder

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

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.

getVectorFieldBuilder()

public StructuredQuery.FieldReference.Builder getVectorFieldBuilder()

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.Builder

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.

internalGetFieldAccessorTable()

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

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeDistanceThreshold(DoubleValue value)

public StructuredQuery.FindNearest.Builder mergeDistanceThreshold(DoubleValue value)

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];

Parameter
Name Description
value DoubleValue
Returns
Type Description
StructuredQuery.FindNearest.Builder

mergeFrom(StructuredQuery.FindNearest other)

public StructuredQuery.FindNearest.Builder mergeFrom(StructuredQuery.FindNearest other)
Parameter
Name Description
other StructuredQuery.FindNearest
Returns
Type Description
StructuredQuery.FindNearest.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public StructuredQuery.FindNearest.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public StructuredQuery.FindNearest.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

mergeLimit(Int32Value value)

public StructuredQuery.FindNearest.Builder mergeLimit(Int32Value value)

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];

Parameter
Name Description
value Int32Value
Returns
Type Description
StructuredQuery.FindNearest.Builder

mergeQueryVector(Value value)

public StructuredQuery.FindNearest.Builder mergeQueryVector(Value value)

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];

Parameter
Name Description
value Value
Returns
Type Description
StructuredQuery.FindNearest.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final StructuredQuery.FindNearest.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

mergeVectorField(StructuredQuery.FieldReference value)

public StructuredQuery.FindNearest.Builder mergeVectorField(StructuredQuery.FieldReference value)

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];

Parameter
Name Description
value StructuredQuery.FieldReference
Returns
Type Description
StructuredQuery.FindNearest.Builder

setDistanceMeasure(StructuredQuery.FindNearest.DistanceMeasure value)

public StructuredQuery.FindNearest.Builder setDistanceMeasure(StructuredQuery.FindNearest.DistanceMeasure value)

Required. The distance measure to use, required.

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

Parameter
Name Description
value StructuredQuery.FindNearest.DistanceMeasure

The distanceMeasure to set.

Returns
Type Description
StructuredQuery.FindNearest.Builder

This builder for chaining.

setDistanceMeasureValue(int value)

public StructuredQuery.FindNearest.Builder setDistanceMeasureValue(int value)

Required. The distance measure to use, required.

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

Parameter
Name Description
value int

The enum numeric value on the wire for distanceMeasure to set.

Returns
Type Description
StructuredQuery.FindNearest.Builder

This builder for chaining.

setDistanceResultField(String value)

public StructuredQuery.FindNearest.Builder setDistanceResultField(String value)

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];

Parameter
Name Description
value String

The distanceResultField to set.

Returns
Type Description
StructuredQuery.FindNearest.Builder

This builder for chaining.

setDistanceResultFieldBytes(ByteString value)

public StructuredQuery.FindNearest.Builder setDistanceResultFieldBytes(ByteString value)

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];

Parameter
Name Description
value ByteString

The bytes for distanceResultField to set.

Returns
Type Description
StructuredQuery.FindNearest.Builder

This builder for chaining.

setDistanceThreshold(DoubleValue value)

public StructuredQuery.FindNearest.Builder setDistanceThreshold(DoubleValue value)

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];

Parameter
Name Description
value DoubleValue
Returns
Type Description
StructuredQuery.FindNearest.Builder

setDistanceThreshold(DoubleValue.Builder builderForValue)

public StructuredQuery.FindNearest.Builder setDistanceThreshold(DoubleValue.Builder builderForValue)

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];

Parameter
Name Description
builderForValue Builder
Returns
Type Description
StructuredQuery.FindNearest.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public StructuredQuery.FindNearest.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

setLimit(Int32Value value)

public StructuredQuery.FindNearest.Builder setLimit(Int32Value value)

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];

Parameter
Name Description
value Int32Value
Returns
Type Description
StructuredQuery.FindNearest.Builder

setLimit(Int32Value.Builder builderForValue)

public StructuredQuery.FindNearest.Builder setLimit(Int32Value.Builder builderForValue)

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];

Parameter
Name Description
builderForValue Builder
Returns
Type Description
StructuredQuery.FindNearest.Builder

setQueryVector(Value value)

public StructuredQuery.FindNearest.Builder setQueryVector(Value value)

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];

Parameter
Name Description
value Value
Returns
Type Description
StructuredQuery.FindNearest.Builder

setQueryVector(Value.Builder builderForValue)

public StructuredQuery.FindNearest.Builder setQueryVector(Value.Builder builderForValue)

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];

Parameter
Name Description
builderForValue Value.Builder
Returns
Type Description
StructuredQuery.FindNearest.Builder

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public StructuredQuery.FindNearest.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

setUnknownFields(UnknownFieldSet unknownFields)

public final StructuredQuery.FindNearest.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
StructuredQuery.FindNearest.Builder
Overrides

setVectorField(StructuredQuery.FieldReference value)

public StructuredQuery.FindNearest.Builder setVectorField(StructuredQuery.FieldReference value)

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];

Parameter
Name Description
value StructuredQuery.FieldReference
Returns
Type Description
StructuredQuery.FindNearest.Builder

setVectorField(StructuredQuery.FieldReference.Builder builderForValue)

public StructuredQuery.FindNearest.Builder setVectorField(StructuredQuery.FieldReference.Builder builderForValue)

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];

Parameter
Name Description
builderForValue StructuredQuery.FieldReference.Builder
Returns
Type Description
StructuredQuery.FindNearest.Builder