public sealed class StructuredQuery : IMessage<StructuredQuery>, IEquatable<StructuredQuery>, IDeepCloneable<StructuredQuery>, IBufferMessage, IMessage
Reference documentation and code samples for the Firestore v1 API class StructuredQuery.
A Firestore query.
The query stages are executed in the following order:
- from
- where
- select
- order_by + start_at + end_at
- offset
- limit
Implements
IMessageStructuredQuery, IEquatableStructuredQuery, IDeepCloneableStructuredQuery, IBufferMessage, IMessageNamespace
Google.Cloud.Firestore.V1Assembly
Google.Cloud.Firestore.V1.dll
Constructors
StructuredQuery()
public StructuredQuery()
StructuredQuery(StructuredQuery)
public StructuredQuery(StructuredQuery other)
Parameter | |
---|---|
Name | Description |
other |
StructuredQuery |
Properties
EndAt
public Cursor EndAt { get; set; }
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.
Property Value | |
---|---|
Type | Description |
Cursor |
FindNearest
public StructuredQuery.Types.FindNearest FindNearest { get; set; }
Optional. A potential Nearest Neighbors Search.
Applies after all other filters and ordering.
Finds the closest vector embeddings to the given query vector.
Property Value | |
---|---|
Type | Description |
StructuredQueryTypesFindNearest |
From
public RepeatedField<StructuredQuery.Types.CollectionSelector> From { get; }
The collections to query.
Property Value | |
---|---|
Type | Description |
RepeatedFieldStructuredQueryTypesCollectionSelector |
Limit
public int? Limit { get; set; }
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.
Property Value | |
---|---|
Type | Description |
int |
Offset
public int Offset { get; set; }
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.
Property Value | |
---|---|
Type | Description |
int |
OrderBy
public RepeatedField<StructuredQuery.Types.Order> OrderBy { get; }
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
becomesORDER BY a ASC, __name__ ASC
ORDER BY a DESC
becomesORDER BY a DESC, __name__ DESC
WHERE a > 1
becomesWHERE a > 1 ORDER BY a ASC, __name__ ASC
WHERE __name__ > ... AND a > 1
becomesWHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC
Property Value | |
---|---|
Type | Description |
RepeatedFieldStructuredQueryTypesOrder |
Select
public StructuredQuery.Types.Projection Select { get; set; }
Optional sub-set of the fields to return.
This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the documents returned from a query. When not set, assumes that the caller wants all fields returned.
Property Value | |
---|---|
Type | Description |
StructuredQueryTypesProjection |
StartAt
public Cursor StartAt { get; set; }
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 beforea = 1 AND b > 2 AND __name__ > /k/123
.START AFTER (10)
: start the query right aftera = 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.
Property Value | |
---|---|
Type | Description |
Cursor |
Where
public StructuredQuery.Types.Filter Where { get; set; }
The filter to apply.
Property Value | |
---|---|
Type | Description |
StructuredQueryTypesFilter |