Class StructuredQuery (3.21.3)

public final class StructuredQuery extends GeneratedMessageV3 implements StructuredQueryOrBuilder

A Firestore query.

The query stages are executed in the following order:

  1. from
  2. where
  3. select
  4. order_by + start_at + end_at
  5. offset
  6. limit

Protobuf type google.firestore.v1.StructuredQuery

Static Fields

END_AT_FIELD_NUMBER

public static final int END_AT_FIELD_NUMBER
Field Value
Type Description
int

FIND_NEAREST_FIELD_NUMBER

public static final int FIND_NEAREST_FIELD_NUMBER
Field Value
Type Description
int

FROM_FIELD_NUMBER

public static final int FROM_FIELD_NUMBER
Field Value
Type Description
int

LIMIT_FIELD_NUMBER

public static final int LIMIT_FIELD_NUMBER
Field Value
Type Description
int

OFFSET_FIELD_NUMBER

public static final int OFFSET_FIELD_NUMBER
Field Value
Type Description
int

ORDER_BY_FIELD_NUMBER

public static final int ORDER_BY_FIELD_NUMBER
Field Value
Type Description
int

SELECT_FIELD_NUMBER

public static final int SELECT_FIELD_NUMBER
Field Value
Type Description
int

START_AT_FIELD_NUMBER

public static final int START_AT_FIELD_NUMBER
Field Value
Type Description
int

WHERE_FIELD_NUMBER

public static final int WHERE_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static StructuredQuery getDefaultInstance()
Returns
Type Description
StructuredQuery

getDescriptor()

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

newBuilder()

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

newBuilder(StructuredQuery prototype)

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

parseDelimitedFrom(InputStream input)

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

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

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

parseFrom(byte[] data)

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

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

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

parseFrom(ByteString data)

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

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

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

parseFrom(CodedInputStream input)

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

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

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

parseFrom(InputStream input)

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

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

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

parseFrom(ByteBuffer data)

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

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

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

parser()

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

Methods

equals(Object obj)

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

getDefaultInstanceForType()

public StructuredQuery getDefaultInstanceForType()
Returns
Type Description
StructuredQuery

getEndAt()

public 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
Cursor

The endAt.

getEndAtOrBuilder()

public 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
CursorOrBuilder

getFindNearest()

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

The findNearest.

getFindNearestOrBuilder()

public 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
StructuredQuery.FindNearestOrBuilder

getFrom(int index)

public StructuredQuery.CollectionSelector getFrom(int index)

The collections to query.

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

Parameter
Name Description
index int
Returns
Type Description
StructuredQuery.CollectionSelector

getFromCount()

public int getFromCount()

The collections to query.

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

Returns
Type Description
int

getFromList()

public List<StructuredQuery.CollectionSelector> getFromList()

The collections to query.

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

Returns
Type Description
List<CollectionSelector>

getFromOrBuilder(int index)

public StructuredQuery.CollectionSelectorOrBuilder getFromOrBuilder(int index)

The collections to query.

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

Parameter
Name Description
index int
Returns
Type Description
StructuredQuery.CollectionSelectorOrBuilder

getFromOrBuilderList()

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

The collections to query.

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

Returns
Type Description
List<? extends com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder>

getLimit()

public 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
Int32Value

The limit.

getLimitOrBuilder()

public 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
Int32ValueOrBuilder

getOffset()

public 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
int

The offset.

getOrderBy(int index)

public StructuredQuery.Order getOrderBy(int index)

The order to apply to the query results.

Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, 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

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

Parameter
Name Description
index int
Returns
Type Description
StructuredQuery.Order

getOrderByCount()

public int getOrderByCount()

The order to apply to the query results.

Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, 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

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

Returns
Type Description
int

getOrderByList()

public List<StructuredQuery.Order> getOrderByList()

The order to apply to the query results.

Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, 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

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

Returns
Type Description
List<Order>

getOrderByOrBuilder(int index)

public StructuredQuery.OrderOrBuilder getOrderByOrBuilder(int index)

The order to apply to the query results.

Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, 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

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

Parameter
Name Description
index int
Returns
Type Description
StructuredQuery.OrderOrBuilder

getOrderByOrBuilderList()

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

The order to apply to the query results.

Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, 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

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

Returns
Type Description
List<? extends com.google.firestore.v1.StructuredQuery.OrderOrBuilder>

getParserForType()

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

getSelect()

public 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
StructuredQuery.Projection

The select.

getSelectOrBuilder()

public 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
StructuredQuery.ProjectionOrBuilder

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
int
Overrides

getStartAt()

public 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.
  • 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.

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

    Returns
    Type Description
    Cursor

    The startAt.

    getStartAtOrBuilder()

    public 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.
  • 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.

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

    Returns
    Type Description
    CursorOrBuilder

    getWhere()

    public StructuredQuery.Filter getWhere()

    The filter to apply.

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

    Returns
    Type Description
    StructuredQuery.Filter

    The where.

    getWhereOrBuilder()

    public StructuredQuery.FilterOrBuilder getWhereOrBuilder()

    The filter to apply.

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

    Returns
    Type Description
    StructuredQuery.FilterOrBuilder

    hasEndAt()

    public 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
    boolean

    Whether the endAt field is set.

    hasFindNearest()

    public 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
    boolean

    Whether the findNearest field is set.

    hasLimit()

    public 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
    boolean

    Whether the limit field is set.

    hasSelect()

    public 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
    boolean

    Whether the select field is set.

    hasStartAt()

    public 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.
  • 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.

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

    Returns
    Type Description
    boolean

    Whether the startAt field is set.

    hasWhere()

    public boolean hasWhere()

    The filter to apply.

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

    Returns
    Type Description
    boolean

    Whether the where 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.Builder newBuilderForType()
    Returns
    Type Description
    StructuredQuery.Builder

    newBuilderForType(GeneratedMessageV3.BuilderParent parent)

    protected StructuredQuery.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
    Parameter
    Name Description
    parent BuilderParent
    Returns
    Type Description
    StructuredQuery.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.Builder toBuilder()
    Returns
    Type Description
    StructuredQuery.Builder

    writeTo(CodedOutputStream output)

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