# Interface StructuredQuery.FindNearestOrBuilder (3.43.1)

3.43.1 (latest) 3.41.0 3.38.0 3.37.0 3.36.0 3.35.1 3.33.4 3.32.2 3.31.9 3.30.11 3.28.0 3.27.2 3.26.5 3.25.1 3.24.3 3.22.0 3.21.4 3.20.0 3.17.0 3.16.3 3.15.7 3.14.4 3.13.2 3.12.1 3.11.0 3.10.0 3.9.6 3.8.2 3.7.10 3.6.0 3.5.0 3.4.2 3.3.0 3.2.0 3.1.0 3.0.21

    public static interface StructuredQuery.FindNearestOrBuilder extends MessageOrBuilder

## Implements

[MessageOrBuilder](https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder.html)

## Methods

### getDistanceMeasure()

    public abstract 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure` | The distanceMeasure. |

### getDistanceMeasureValue()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | The enum numeric value on the wire for distanceMeasure. |

### getDistanceResultField()

    public abstract 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** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The distanceResultField. |

### getDistanceResultFieldBytes()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` | The bytes for distanceResultField. |

### getDistanceThreshold()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.DoubleValue.html` | The distanceThreshold. |

### getDistanceThresholdOrBuilder()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.DoubleValueOrBuilder.html` |   |

### getLimit()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Int32Value.html` | The limit. |

### getLimitOrBuilder()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Int32ValueOrBuilder.html` |   |

### getQueryVector()

    public abstract 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Value` | The queryVector. |

### getQueryVectorOrBuilder()

    public abstract 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ValueOrBuilder` |   |

### getVectorField()

    public abstract 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.FieldReference` | The vectorField. |

### getVectorFieldOrBuilder()

    public abstract 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder` |   |

### hasDistanceThreshold()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the distanceThreshold field is set. |

### hasLimit()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the limit field is set. |

### hasQueryVector()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the queryVector field is set. |

### hasVectorField()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the vectorField field is set. |