# Interface StructuredQueryOrBuilder (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 interface StructuredQueryOrBuilder extends MessageOrBuilder

## Implements

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

## Methods

### getEndAt()

    public abstract Cursor getEndAt()

A potential prefix of a position in the result set to end the query at.

This is similar to `START_AT` but with it controlling the end position
rather than the start position.

Requires:

- The number of values cannot be greater than the number of fields specified in the `ORDER BY` clause.

`.google.firestore.v1.Cursor end_at = 8;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Cursor` | The endAt. |

### getEndAtOrBuilder()

    public abstract CursorOrBuilder getEndAtOrBuilder()

A potential prefix of a position in the result set to end the query at.

This is similar to `START_AT` but with it controlling the end position
rather than the start position.

Requires:

- The number of values cannot be greater than the number of fields specified in the `ORDER BY` clause.

`.google.firestore.v1.Cursor end_at = 8;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CursorOrBuilder` |   |

### getFindNearest()

    public abstract StructuredQuery.FindNearest getFindNearest()

Optional. A potential nearest neighbors search.

Applies after all other filters and ordering.

Finds the closest vector embeddings to the given query vector.

`
.google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL];
`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.FindNearest` | The findNearest. |

### getFindNearestOrBuilder()

    public abstract StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder()

Optional. A potential nearest neighbors search.

Applies after all other filters and ordering.

Finds the closest vector embeddings to the given query vector.

`
.google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL];
`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder` |   |

### getFrom(int index)

    public abstract StructuredQuery.CollectionSelector getFrom(int index)

The collections to query.

`repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `index` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.CollectionSelector` |   |

### getFromCount()

    public abstract int getFromCount()

The collections to query.

`repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getFromList()

    public abstract List<StructuredQuery.CollectionSelector> getFromList()

The collections to query.

`repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.CollectionSelector>` |   |

### getFromOrBuilder(int index)

    public abstract StructuredQuery.CollectionSelectorOrBuilder getFromOrBuilder(int index)

The collections to query.

`repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `index` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder` |   |

### getFromOrBuilderList()

    public abstract List<? extends StructuredQuery.CollectionSelectorOrBuilder> getFromOrBuilderList()

The collections to query.

`repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<? extends com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder>` |   |

### getLimit()

    public abstract Int32Value getLimit()

The maximum number of results to return.

Applies after all other constraints.

Requires:

- The value must be greater than or equal to zero if specified.

`.google.protobuf.Int32Value limit = 5;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Int32Value.html` | The limit. |

### getLimitOrBuilder()

    public abstract Int32ValueOrBuilder getLimitOrBuilder()

The maximum number of results to return.

Applies after all other constraints.

Requires:

- The value must be greater than or equal to zero if specified.

`.google.protobuf.Int32Value limit = 5;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Int32ValueOrBuilder.html` |   |

### getOffset()

    public abstract int getOffset()

The number of documents to skip before returning the first result.

This applies after the constraints specified by the `WHERE`, `START AT`, \&
`END AT` but before the `LIMIT` clause.

Requires:

- The value must be greater than or equal to zero if specified.

`int32 offset = 6;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | The offset. |

### getOrderBy(int index)

    public abstract StructuredQuery.Order getOrderBy(int index)

The order to apply to the query results.

Callers can provide a full ordering, a partial ordering, or no ordering at
all. While Firestore will always respect the provided order, the behavior
for queries without a full ordering is different per database edition:

In Standard edition, Firestore guarantees a stable ordering through the
following rules:

- The `order_by` is required to reference all fields used with an inequality filter.
- All fields that are required to be in the `order_by` but are not already present are appended in lexicographical ordering of the field name.
- If an order on `name` is not specified, it is appended by default.

  Fields are appended with the same sort direction as the last order
  specified, or 'ASCENDING' if no order was specified. For example:
- `ORDER BY a` becomes `ORDER BY a ASC, name ASC`

- `ORDER BY a DESC` becomes `ORDER BY a DESC, name DESC`
- `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, name ASC`
- `WHERE name > ... AND a > 1` becomes
  `WHERE name > ... AND a > 1 ORDER BY a ASC, name ASC`

  In Enterprise edition, Firestore does not guarantee a stable ordering.
  Instead it will pick the most efficient ordering based on the indexes
  available at the time of query execution. This will result in a different
  ordering for queries that are otherwise identical. To ensure a stable
  ordering, always include a unique field in the `order_by` clause, such as
  `name`.

`repeated .google.firestore.v1.StructuredQuery.Order order_by = 4;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `index` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.Order` |   |

### getOrderByCount()

    public abstract int getOrderByCount()

The order to apply to the query results.

Callers can provide a full ordering, a partial ordering, or no ordering at
all. While Firestore will always respect the provided order, the behavior
for queries without a full ordering is different per database edition:

In Standard edition, Firestore guarantees a stable ordering through the
following rules:

- The `order_by` is required to reference all fields used with an inequality filter.
- All fields that are required to be in the `order_by` but are not already present are appended in lexicographical ordering of the field name.
- If an order on `name` is not specified, it is appended by default.

  Fields are appended with the same sort direction as the last order
  specified, or 'ASCENDING' if no order was specified. For example:
- `ORDER BY a` becomes `ORDER BY a ASC, name ASC`

- `ORDER BY a DESC` becomes `ORDER BY a DESC, name DESC`
- `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, name ASC`
- `WHERE name > ... AND a > 1` becomes
  `WHERE name > ... AND a > 1 ORDER BY a ASC, name ASC`

  In Enterprise edition, Firestore does not guarantee a stable ordering.
  Instead it will pick the most efficient ordering based on the indexes
  available at the time of query execution. This will result in a different
  ordering for queries that are otherwise identical. To ensure a stable
  ordering, always include a unique field in the `order_by` clause, such as
  `name`.

`repeated .google.firestore.v1.StructuredQuery.Order order_by = 4;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getOrderByList()

    public abstract List<StructuredQuery.Order> getOrderByList()

The order to apply to the query results.

Callers can provide a full ordering, a partial ordering, or no ordering at
all. While Firestore will always respect the provided order, the behavior
for queries without a full ordering is different per database edition:

In Standard edition, Firestore guarantees a stable ordering through the
following rules:

- The `order_by` is required to reference all fields used with an inequality filter.
- All fields that are required to be in the `order_by` but are not already present are appended in lexicographical ordering of the field name.
- If an order on `name` is not specified, it is appended by default.

  Fields are appended with the same sort direction as the last order
  specified, or 'ASCENDING' if no order was specified. For example:
- `ORDER BY a` becomes `ORDER BY a ASC, name ASC`

- `ORDER BY a DESC` becomes `ORDER BY a DESC, name DESC`
- `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, name ASC`
- `WHERE name > ... AND a > 1` becomes
  `WHERE name > ... AND a > 1 ORDER BY a ASC, name ASC`

  In Enterprise edition, Firestore does not guarantee a stable ordering.
  Instead it will pick the most efficient ordering based on the indexes
  available at the time of query execution. This will result in a different
  ordering for queries that are otherwise identical. To ensure a stable
  ordering, always include a unique field in the `order_by` clause, such as
  `name`.

`repeated .google.firestore.v1.StructuredQuery.Order order_by = 4;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.Order>` |   |

### getOrderByOrBuilder(int index)

    public abstract StructuredQuery.OrderOrBuilder getOrderByOrBuilder(int index)

The order to apply to the query results.

Callers can provide a full ordering, a partial ordering, or no ordering at
all. While Firestore will always respect the provided order, the behavior
for queries without a full ordering is different per database edition:

In Standard edition, Firestore guarantees a stable ordering through the
following rules:

- The `order_by` is required to reference all fields used with an inequality filter.
- All fields that are required to be in the `order_by` but are not already present are appended in lexicographical ordering of the field name.
- If an order on `name` is not specified, it is appended by default.

  Fields are appended with the same sort direction as the last order
  specified, or 'ASCENDING' if no order was specified. For example:
- `ORDER BY a` becomes `ORDER BY a ASC, name ASC`

- `ORDER BY a DESC` becomes `ORDER BY a DESC, name DESC`
- `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, name ASC`
- `WHERE name > ... AND a > 1` becomes
  `WHERE name > ... AND a > 1 ORDER BY a ASC, name ASC`

  In Enterprise edition, Firestore does not guarantee a stable ordering.
  Instead it will pick the most efficient ordering based on the indexes
  available at the time of query execution. This will result in a different
  ordering for queries that are otherwise identical. To ensure a stable
  ordering, always include a unique field in the `order_by` clause, such as
  `name`.

`repeated .google.firestore.v1.StructuredQuery.Order order_by = 4;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `index` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.OrderOrBuilder` |   |

### getOrderByOrBuilderList()

    public abstract List<? extends StructuredQuery.OrderOrBuilder> getOrderByOrBuilderList()

The order to apply to the query results.

Callers can provide a full ordering, a partial ordering, or no ordering at
all. While Firestore will always respect the provided order, the behavior
for queries without a full ordering is different per database edition:

In Standard edition, Firestore guarantees a stable ordering through the
following rules:

- The `order_by` is required to reference all fields used with an inequality filter.
- All fields that are required to be in the `order_by` but are not already present are appended in lexicographical ordering of the field name.
- If an order on `name` is not specified, it is appended by default.

  Fields are appended with the same sort direction as the last order
  specified, or 'ASCENDING' if no order was specified. For example:
- `ORDER BY a` becomes `ORDER BY a ASC, name ASC`

- `ORDER BY a DESC` becomes `ORDER BY a DESC, name DESC`
- `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, name ASC`
- `WHERE name > ... AND a > 1` becomes
  `WHERE name > ... AND a > 1 ORDER BY a ASC, name ASC`

  In Enterprise edition, Firestore does not guarantee a stable ordering.
  Instead it will pick the most efficient ordering based on the indexes
  available at the time of query execution. This will result in a different
  ordering for queries that are otherwise identical. To ensure a stable
  ordering, always include a unique field in the `order_by` clause, such as
  `name`.

`repeated .google.firestore.v1.StructuredQuery.Order order_by = 4;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<? extends com.google.firestore.v1.StructuredQuery.OrderOrBuilder>` |   |

### getSelect()

    public abstract StructuredQuery.Projection getSelect()

Optional sub-set of the fields to return.

This acts as a DocumentMask over the
documents returned from a query. When not set, assumes that the caller
wants all fields returned.

`.google.firestore.v1.StructuredQuery.Projection select = 1;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.Projection` | The select. |

### getSelectOrBuilder()

    public abstract StructuredQuery.ProjectionOrBuilder getSelectOrBuilder()

Optional sub-set of the fields to return.

This acts as a DocumentMask over the
documents returned from a query. When not set, assumes that the caller
wants all fields returned.

`.google.firestore.v1.StructuredQuery.Projection select = 1;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder` |   |

### getStartAt()

    public abstract Cursor getStartAt()

A potential prefix of a position in the result set to start the query at.

The ordering of the result set is based on the `ORDER BY` clause of the
original query.

\``` `
SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, name ASC;
` ``

`
`

` This query's results are ordered by `(b ASC, **name** ASC)`.`

`
`

` Cursors can reference either the full ordering or a prefix of the location,
though it cannot reference more fields than what are in the provided
`ORDER BY`.`

`
`

` Continuing off the example above, attaching the following start cursors
will have varying impact:`
`


-
`START BEFORE (2, /k/123)`: start the query right before `a = 1 AND b \> 2 AND **name** \> /k/123`.

- <br />


`START AFTER (10)`: start the query right after `a = 1 AND b \> 10`.


`

`Unlike `OFFSET` which requires scanning over the first N results to skip,
a start cursor allows the query to begin at a logical position. This
position is not required to match an actual result, it will scan forward
from this position to find the next document.`

`
`

`Requires:`
`


- The number of values cannot be greater than the number of fields
specified in the


`ORDER BY\` clause.

<br />

`.google.firestore.v1.Cursor start_at = 7;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Cursor` | The startAt. |

### getStartAtOrBuilder()

    public abstract CursorOrBuilder getStartAtOrBuilder()

A potential prefix of a position in the result set to start the query at.

The ordering of the result set is based on the `ORDER BY` clause of the
original query.

\``` `
SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, name ASC;
` ``

`
`

` This query's results are ordered by `(b ASC, **name** ASC)`.`

`
`

` Cursors can reference either the full ordering or a prefix of the location,
though it cannot reference more fields than what are in the provided
`ORDER BY`.`

`
`

` Continuing off the example above, attaching the following start cursors
will have varying impact:`
`


-
`START BEFORE (2, /k/123)`: start the query right before `a = 1 AND b \> 2 AND **name** \> /k/123`.

- <br />


`START AFTER (10)`: start the query right after `a = 1 AND b \> 10`.


`

`Unlike `OFFSET` which requires scanning over the first N results to skip,
a start cursor allows the query to begin at a logical position. This
position is not required to match an actual result, it will scan forward
from this position to find the next document.`

`
`

`Requires:`
`


- The number of values cannot be greater than the number of fields
specified in the


`ORDER BY\` clause.

<br />

`.google.firestore.v1.Cursor start_at = 7;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CursorOrBuilder` |   |

### getWhere()

    public abstract StructuredQuery.Filter getWhere()

The filter to apply.

`.google.firestore.v1.StructuredQuery.Filter where = 3;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.Filter` | The where. |

### getWhereOrBuilder()

    public abstract StructuredQuery.FilterOrBuilder getWhereOrBuilder()

The filter to apply.

`.google.firestore.v1.StructuredQuery.Filter where = 3;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.StructuredQuery.FilterOrBuilder` |   |

### hasEndAt()

    public abstract boolean hasEndAt()

A potential prefix of a position in the result set to end the query at.

This is similar to `START_AT` but with it controlling the end position
rather than the start position.

Requires:

- The number of values cannot be greater than the number of fields specified in the `ORDER BY` clause.

`.google.firestore.v1.Cursor end_at = 8;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the endAt field is set. |

### hasFindNearest()

    public abstract boolean hasFindNearest()

Optional. A potential nearest neighbors search.

Applies after all other filters and ordering.

Finds the closest vector embeddings to the given query vector.

`
.google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL];
`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the findNearest field is set. |

### hasLimit()

    public abstract boolean hasLimit()

The maximum number of results to return.

Applies after all other constraints.

Requires:

- The value must be greater than or equal to zero if specified.

`.google.protobuf.Int32Value limit = 5;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the limit field is set. |

### hasSelect()

    public abstract boolean hasSelect()

Optional sub-set of the fields to return.

This acts as a DocumentMask over the
documents returned from a query. When not set, assumes that the caller
wants all fields returned.

`.google.firestore.v1.StructuredQuery.Projection select = 1;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the select field is set. |

### hasStartAt()

    public abstract boolean hasStartAt()

A potential prefix of a position in the result set to start the query at.

The ordering of the result set is based on the `ORDER BY` clause of the
original query.

\``` `
SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, name ASC;
` ``

`
`

` This query's results are ordered by `(b ASC, **name** ASC)`.`

`
`

` Cursors can reference either the full ordering or a prefix of the location,
though it cannot reference more fields than what are in the provided
`ORDER BY`.`

`
`

` Continuing off the example above, attaching the following start cursors
will have varying impact:`
`


-
`START BEFORE (2, /k/123)`: start the query right before `a = 1 AND b \> 2 AND **name** \> /k/123`.

- <br />


`START AFTER (10)`: start the query right after `a = 1 AND b \> 10`.


`

`Unlike `OFFSET` which requires scanning over the first N results to skip,
a start cursor allows the query to begin at a logical position. This
position is not required to match an actual result, it will scan forward
from this position to find the next document.`

`
`

`Requires:`
`


- The number of values cannot be greater than the number of fields
specified in the


`ORDER BY\` clause.

<br />

`.google.firestore.v1.Cursor start_at = 7;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the startAt field is set. |

### hasWhere()

    public abstract boolean hasWhere()

The filter to apply.

`.google.firestore.v1.StructuredQuery.Filter where = 3;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the where field is set. |